本人刚刚接触Struts2,今天在做网上教的一个小项目时,总是报404错,不知道是为什么
项目情况如下:
工具:MyEclipse6.5 Tomcat5.0
JDK1.6
Struts2版本2.2web.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.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>struts.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="bixy" namespace="/" extends="struts-default">
<action name="hello" class="org.bixy.struts2.demo.HelloStruts">
<result name="suc">/hello.jsp</result>
<result name="err">/err.jsp</result>
</action>
</package>
</struts>在web.xml中配置Struts2 的Filter之前,可以访问到index.jsp页面,配完Filter之后,就报404错了,望前辈指教
项目情况如下:
工具:MyEclipse6.5 Tomcat5.0
JDK1.6
Struts2版本2.2web.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.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>struts.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="bixy" namespace="/" extends="struts-default">
<action name="hello" class="org.bixy.struts2.demo.HelloStruts">
<result name="suc">/hello.jsp</result>
<result name="err">/err.jsp</result>
</action>
</package>
</struts>在web.xml中配置Struts2 的Filter之前,可以访问到index.jsp页面,配完Filter之后,就报404错了,望前辈指教
<action name="sellorderAction" class="com.popuEmenu.action.sellorderAction">
然后访问的路径
<%
if(session.getAttribute("list")==null){
response.sendRedirect("LoginMenuAction!login");
}
%>
这是个列子.页面得到的list为空时访问
<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>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
楼主试试看~~
我的web.xml配置文件中,
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
org.apache,还有ng下面划黄线,说我拼写不正确,我看jar包里面,这个路径是正确的啊
<Context path="/struts2" docBase="D:\Workspaces\Struts2\WebRoot" reloadable="true"/>
访问的时候输入的是:http://localhost:8080/struts2然后页面报404错,说The requested resource (/struts2/) is not available如果不加web.xml 中filter的配置,可以正常访问
是你的过滤器问题,和别的没有关系。因为你没有配之前是可以访问的,所以在/*之前调用过滤的问题,。
Tomcat换成6.0 ,就好了,谢谢大家