Eclipse Helios の Tomcat v6.0.35 で単純な Web アプリケーションを実行しようとしています。サーブレットを実行しようとすると、ブラウザで次のエラーが発生します。
ステータス レポート:"メッセージ HTTP メソッド GET は、この URL ではサポートされていません" 説明: "指定された HTTP メソッドは、要求されたリソースに対して許可されていません (HTTP メソッド GET は、この URL ではサポートされていません)" これが私の 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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>servletDemo</display-name>
<servlet-name>DemoServlet</servlet-name>
<servlet-class>com.lara.DemoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DemoServlet</servlet-name>
<url-pattern>/servletDemo.do</url-pattern>
</servlet-mapping>
</web-app>
そして、これはhtmlファイルindex.htmlです
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="DemoServlet"method="post">
<input type="submit" value="submit">
</form>
</body>
</html>
これは DemoServlet.java です
package com.lara;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DemoServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public DemoServlet()
{
super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter pw=response.getWriter();
System.out.print("1st appp demo...!!!");
}
}
私のフォルダ構成はこんな感じです...
クラス ファイルも WEB-INF\classes forer に入り、\servletDemo や index.html などのさまざまなマッピング スタイルで web.xml も試しましたが、私のサーブレットはブラウザーで実行されていませんが、インデックス ファイルはブラウザーで実行されています。ブラウザ..:(