我做我的struts2的應用程序,所以我是儘量包括Struts的不斷struts.action.extension到JSP擴展,但其顯示找不到網頁error.Here是代碼是我的嘗試,struts.action.extension爲「jsp的」不工作
的struts.xml:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- <constant name="struts.devMode" value="true"></constant>-->
<constant name="struts.action.extension" value="jsp"/>
<package name="default" namespace="/" extends="struts-default" >
<action name="LoginClass" class="com.struts2.LoginCheckingClass" method="execute">
<result name="success">/LoginSuccessPage.jsp</result>
<result name="input">/Home.jsp</result>
</action>
</package>
</struts>
回到Home.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:form action="LoginClass" method="post">
<s:textfield name="Uname" label="User Name" />
<s:textfield name="Pwd" label="Password" />
<s:submit Value="Login" />
</s:form>
</body>
</html>
我們B.XML:
<web-app 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"
version="2.5">
<display-name>Struts2Application</display-name>
<welcome-file-list>
<welcome-file>home.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
應用程序運行完美(http://localhost:8080/Struts2Application/LoginClass.action
)當我刪除<constant name="struts.action.extension" value="jsp"/>
,但我想在http://localhost:8080/Struts2Application/LoginClass.jsp
運行。我看過很多鏈接,但沒有任何幫助。
注:我用struts 2.3.20
有人告訴我該怎麼解決這個問題?
更新:
看到我的應用程序結構在這裏。
你'Home.jsp'文件不' home.jsp'。在你的屏幕截圖中,有'html'擴展名而不是'jsp',所以很顯然它不適用於'LoginClass.jsp'。 – 2015-03-03 14:49:19
一般來說,您需要在點擊歡迎頁面後重定向到操作。現在,您正嘗試點擊'.../Home.jsp'網址,該網址將被解釋爲操作命中,但您沒有使用「主」名稱的操作。 – 2015-03-04 11:04:03