Struts2を学習しようとしていますが、動作するhello worldアプリケーションを作成できません。 JSPから要求があった場合、404(ページが見つかりません)というエラーが出ます。 libフォルダにlibファイルをすべて保存したまま、struts.xml
をクラスフォルダ内に配置しましたが、まだこのエラーが発生しています。ここでJSPから要求があったときに404エラーが発生する
は図である。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<form action="HelloWorld">
<input type="submit">
</form>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
これは私のstruts.xml
ファイル
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="HelloWorld" class="vaannila.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
</package>
</struts>
これはエラーです:
HTTP Status 404 - /Testi/HelloWorld
type Status report
message /Testi/HelloWorld
description The requested resource (/Testi/HelloWorld) is not available.
Apache Tomcat/6.0.33
はどのようにこれをやっていますか? Eclipse IDEを使用していて、tomcatをサーバーとして追加しましたか?その最初のhtml/jspコードのファイル名は何ですか – Jayy
これは、struts.xmlが見つからないことや、起動時にStruts2のロードを妨げるその他のエラーが発生している可能性があります。 –