0
我有以下web.xml和struts-config.xml中基本Struts1.2應用程序,它轉發到JSP頁面
的web.xml
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
struts-一個Struts 1.2應用config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="Welcome"
type="com.mugil.tutor.action.Sample" />
</form-beans>
<action-mappings>
<action path="/Welcome" name="Welcome" type="com.mugil.tutor.action.Sample">
<forward name="success" path="/welcome.jsp"/>
</action>
</action-mappings>
</struts-config>
被如下所示
01中的文件的目錄結構我想在welcome.jsp.This顯示歡迎信息應該發生,我收到來自Sample.java
Sample.java
package com.mugil.tutor.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class Sample extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
String target = "success";
return mapping.findForward(target);
}
}
歡迎成功的消息後。 jsp
<title>Insert title here</title>
</head>
<body>
<h1>Welcome to Struts 1.2</h1>
</body>
</html>
我不知道我要去哪裏錯。當我試圖修復它時,它顯示不同的錯誤消息。
什麼錯誤信息? – NINCOMPOOP 2013-05-07 12:19:57
HTTP狀態404 - 請求/welcome.jsp路徑無效 – 2013-05-07 12:21:23
您在哪裏保存了JSP文件? – NINCOMPOOP 2013-05-07 12:22:15