请问下struts配置404错误是肿么回事啊
java吧
全部回复
仅看楼主
level 11
forrest0402 楼主
[吐舌]新人求解,照着书上复制的代码啊
2013年07月30日 14点07分 1
level 11
forrest0402 楼主
我按照书上写滴配置src里头的struts.xml代码如下
<struts>
<package name="itcast" namespace="/test" extends="struts-default">
<action name="helloworld" class="cn.itcast.action.HelloWorldAction"
method="execute">
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
</package>
</struts>
web.xml如下
<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>
然后访问localhost:8080/HappyTimes/test/helloworld出现404错误,那个Happytimes是我工程的名字。。。然后不知道哪里错了,求指教啊,而且我发现webroot下的jsp也全部访问不了
2013年07月30日 14点07分 2
level 7
[点头]前排

2013年07月30日 14点07分 3
[哈哈]前辈这么快
2013年07月30日 14点07分
level 11
forrest0402 楼主
我把web.xml中那段filter删除就可以访问jsp了,不过书上确实有这段啊,我是直接用myeclipse添加的struts2.1支持
2013年07月30日 14点07分 4
level 7
第一:localhost:8080/HappyTimes/test/helloworld.action试试
2013年07月30日 14点07分 5
加了action还是404[泪]
2013年07月30日 14点07分
level 7
web.xml应该没什么问题, 配置项就那么几个

看看你的
struts.xml,检查action配置. 我一次就是因为有一行代码贴到<action></action>块外面了, 结果访问什么都是404
2013年07月30日 14点07分 6
struts.xml就是我贴出的那行,我直接复制过来滴,我看了几遍感觉木有错呢[委屈]
2013年07月30日 14点07分
level 7
第二:<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
改成这个试试:<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
2013年07月30日 14点07分 7
啊,改了以后还是不行,不过提示出错误了,貌似不能加载一个jar文件
2013年07月30日 14点07分
回复 forrest0402 :是不是myeclipse自带的不行,我去网上下载个如何[吐舌]???
2013年07月30日 14点07分
[汗]你没有导入struts2架包吗
2013年07月30日 14点07分
level 11
forrest0402 楼主
Caused by:
Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/F:/apache-tomcat/webapps/HappyTimes/WEB-INF/lib/struts2-core-2.3.15.1.jar!/struts-default.xml:29:72at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)... 20 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/F:/apache-tomcat/webapps/HappyTimes/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:29:72 - bean - jar:file:/F:/apache-tomcat/webapps/HappyTimes/WEB-INF/lib/struts2-core-2.3.15.1.jar!/struts-default.xml:29:72at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)... 23 more
2013年07月30日 14点07分 8
jar 包问题。
2013年07月30日 15点07分
level 4
高不懂为什么要把也面放在 WEB-INF ,求指教 。。。。。。。。
2013年07月30日 14点07分 9
也面是神马[黑线]
2013年07月30日 14点07分
回复 forrest0402 :页面! 就是你的 hello.jsp 页面
2013年07月30日 15点07分
回复 为爱停留丶 :+1
2013年07月31日 03点07分
也面放在 WEB-INF 只能通过action才能访问的到
2013年07月31日 04点07分
level 14
WEB-INF下的内容外界是不能直接访问的
如果改成helloworld也不能访问的话请确定是否存在cn.itcast.action.HelloWorldAction这个类
2013年07月30日 14点07分 10
level 11
你上面的错误信息是你的 jar包问题,你的配置文件都是对的,不过我建议你还上不要 在 strus 配置文件中 加上
method="execute 这个,把这个删掉 因为 他默认就是执行这个 execute 方法、
访问的时候
localhost:8080/HappyTimes/test/helloworld.action 这样访问!
2013年07月30日 15点07分 12
level 8
.jsp文件不是在WebRoot的文件夹里么?
404错误是服务器未找到资源,检查下action文件
2013年07月30日 15点07分 14
level 11
forrest0402 楼主
[乖]问题解决了,我换成myeclipse自带的tomcat就可以了,貌似我从官网下载的那个7.X和哪里哪里可能不兼容之类滴,又或者它的要求不一样[吐舌]
2013年07月31日 04点07分 15
你是学完什么学的Struts?
2013年07月31日 04点07分
1