0

Eclipse IDE を使用して 1 つの動的プロジェクトを作成しました。プロジェクト CollegeManagement の WebContent フォルダー内に 1 つの HTML ページ Welcome.html を追加しました。プロジェクトを Apache Tomcat-7.0.47 にデプロイしました。展開後、Welcome.html を含む C:\apache-tomcat-7.0.47\webapps 内に CollegeManagement フォルダーが 1 つ表示されます。Welcome.html を右クリックして [サーバーで実行] を選択してアプリケーションを実行すると、エラー HTTP 405 が表示されます。誰かこの問題の解決を手伝ってくれませんか? ここでスナップショットを見つけてくださいhttp://imageshack.us/photo/my-images/843/3q0r.png/

プロジェクト構造イメージ: http://imageshack.us/photo/my-images/826/ufep.png/

HTML ページ Welcome.html を含む

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Welcome</title>
</head>
<body>
<form method="post" action="http://localhost:8181/CollegeManagement/do">
Operation<input type="text" name="op"/>
<button type="submit">Do</button>
</form>
</body>
</html>

web.xml を含む

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>CollegeManagement</display-name>
  <welcome-file-list>
   <!--  <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file> -->
     <welcome-file></welcome-file>
  </welcome-file-list>

  <servlet-mapping>
  <servlet-name>welcome</servlet-name>
  <url-pattern>/*</url-pattern>
  </servlet-mapping>
  <servlet>
  <servlet-name>welcome</servlet-name>
  <servlet-class>com.vijay.Welcome</servlet-class>
  </servlet>
</web-app>

サーバー上の静的ページにアクセスしようとしていますが、web.xml または HTML ファイルの内容をチェックせずに返されるはずです。GET メソッドがサポートされていないのはなぜですか?

参考までに: Welcome.html の名前を College.html に変更してみましたが、問題は解決しません。

どうもありがとう。

4

1 に答える 1

0

注 : 最初に、間違った URL パターンがないかどうかを確認します。

以下を使用して、デフォルトのサーブレット コンテナーを確認します。

  <!-- Disables Servlet Container welcome file handling. Needed for compatibility with Servlet 3.0 and Tomcat 7.0 -->
  <welcome-file-list>
    <welcome-file></welcome-file>
  </welcome-file-list>

これは、実際に doGet() を実装せずに doGet() を呼び出している可能性があるためです。メソッドがサポートされていないというエラーをスローするのは、doGet() のデフォルトの実装です。

于 2013-11-04T13:25:06.680 に答える