struts2访问jsp页面404
2016-01-21 12:28
459 查看
问题描述
在搭建struts2环境的时候,拷贝了web.xml,拷贝了struts.xml,拷贝了jar包。运行,正常,访问jsp页面,报404错误。web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>hellostruts2</display-name> <filter> <filter-name>struts</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </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="xxxx" extends="struts-default"> <action name="hello" class="com.zengmg.strtus.HelloAction" method="execute"> <result name="success">/success.jsp</result> </action> </package> </struts>
访问:
http://localhost:8080/strutsfiledemo/success.jsp。报 404!原因:
因为struts.xml配置了的action没有java类与其对应,所以报错。但是我没把控制台的信息拉到上面看,导致没看到信息。Caused by: Action class [com.zengmg.strtus.HelloAction] not found - action - file:/E:/apache-tomcat-8.0.26/webapps/strutsfiledemo/WEB-INF/classes/struts.xml:8:82
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:434)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:378)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:495)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:286)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 16 more
解决方法:
把struts.xml的action删了,或者写好java类,配置正确action。相关文章推荐
- [LeetCode][Java] 3Sum Closest
- 利用java读取配置文件
- 028.Comparator 比较器的使用
- spring 几点基础内容
- Spring3 MVC 拦截器拦截不到的问题
- java.lang.InstantiationException:
- JDK1.5新特性
- 【开卷故意】JAVA正則表達式模版
- Netbeans项目与GitHub代码库同步
- struts2自定义拦截器
- Eclipse/IDEA中使用Maven创建Web项目报错
- Java类与对象===Java变量的作用域
- Spring4.0 + 实现简单的聊天
- Eclipse中65536的解决办法
- java反射学习
- Java程序中加载文件和动态链接库
- java List 排序 Collections.sort()
- Eclipse使用技巧之代码编辑器分隔窗口
- java中for方法执行的正确顺序
- java SSL 简单操作demo