关于struts2的配置问题

busoo86 2010-09-28 03:25:12
最近了解了下struts2,关于web.xml的配置有一个一问:
<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>

在配置“filter-mapping”的url-pattern中都为/*,我现在又加入了一个快速开发的组件,该组件在web.xml中有配置信息:
<servlet>
<servlet-name>djfocus-action</servlet-name>
<servlet-class>com.djfocus.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>djfocus-action</servlet-name>
<url-pattern>/djfocus/servAction</url-pattern>
</servlet-mapping>

结果启动tomcat运行后,在web页面用到了组件的网页就会报错,报错内容如下:
Could not find action or result
There is no Action mapped for action name servAction. - [unknown location]
估计是struts2的配置在解析的时候把servlet-mapping中的url抓取出来了。本人没有深入去研究struts2,想请教下大家,可以解决这个问题嘛,遇到了url-pattern问题?
...全文
93 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xingyanfeng775 2010-09-28
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jspa</url-pattern>
</filter-mapping>
回复
hoojo 2010-09-28
<url-pattern>/djfocus/servAction/*</url-pattern>
servAction命名控件或是目录下的所有请求,具体要看请求地址
也就是地址中有servAction的
回复
jlsf_zym 2010-09-28
曾经的配置,如果还是不行建议直接更改struts的配置 让他拦截*.do
回复
jlsf_zym 2010-09-28
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<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>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/fckeditor/editor/filemanager/connectors/*
</url-pattern>
</servlet-mapping>


</web-app>
回复
busoo86 2010-09-28
Invalid <url-pattern> /*.action in filter mapping
还是不行呢,改成/*.action??
回复
pengzhistar 2010-09-28
肯定会报错啦,你的struts把所有的请求给拦截了!改成楼上的/*.action吧!或者在把这个请求写成一个action呀!干吗用了struts还写自己的servlet类呢 ?
回复
crazylaa 2010-09-28
/*
--->
/*.action
回复
jlsf_zym 2010-09-28
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.action</url-pattern>
</filter-mapping>
可以改成这个样子试试
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2010-09-28 03:25
社区公告
暂无公告