部署用eclipse开发的struts2应用
当我正确部署了struts2应用程序后,在浏览器里输入http://localhost:8080/WebContent/时提示找不到WebContent(WebContent是应用程序根目录);而当我删除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>
但是,由于没了action,所以在进行后面的任务的时候提示找不到action。请问这是怎么回事啊?
(org.apache.struts2.dispatcher.FilterDispatcher换成推荐用的org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter还是不行)
[解决办法]
<?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>dispatcher</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>dispatcher</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>P200.jsp</welcome-file>
</welcome-file-list>
</web-app>