<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>
<url-pattern>*.action</url-pattern> 这怎么不能改成 比如 <url-pattern>aaa.action</url-pattern> 只过滤 aaa.action 这样不行出错,有没有什么办法能这样<url-pattern>aaa.action</url-pattern><url-pattern>*.action</url-pattern> aaa.action这样可以 改成 <url-pattern>*.paln</url-pattern> aaa.paln 这样出404什么原因啊
要改后缀修改配置文件的常量.! 你的意思是,,你用个struts2,就只为过滤一个action.? 我不太明白你这样做的意义是什么喔!
struts.action.extension
配置<constant name="struts.action.extension" value="你要的后缀名,如有多个以逗号隔开">
不行哦2010-06-18 15:38:05 [com.opensymphony.xwork2.util.DomHelper]-[ERROR] Element type "constan" must be declared. at (null:20:58)
org.xml.sax.SAXParseException: Element type "constan" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)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>
<constant name="struts.i18n.encoding" value="GBK" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.devMode" value="false" />
<constan name="struts.action.extension" value="action"></constan>
<include file="struts-default.xml" />
<package name="testDemoAction" extends="struts-default">
<action name="testDemoAction" class="com.haizone.struts.action.test.TestDemoAction">
<result name="select">/test/select.jsp</result>
<result name="checkbox">/test/checkbox.jsp</result>
</action>
</package> <package name="struts2" extends="struts-default">
<interceptors> <interceptor name="authority"
class="com.haizone.interceptors.AuthInterceptor" />
<interceptor-stack name="mydefault"> <interceptor-ref name="defaultStack" /> <interceptor-ref name="authority" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="mydefault" />
<global-results>
<result name="error">/commons/error.jsp</result>
<result name="errorTip">/commons/errorTip.jsp</result>
<result name="no_auth">/commons/no_auth.jsp</result>
<result name="fieldError">/commons/fieldError.jsp</result>
<result name="login">/jsp/home/login.jsp</result>
</global-results>
<!--
<global-exception-mappings>
<exception-mapping result="global"
exception="java.sql.SQLException">
</exception-mapping>
<exception-mapping result="businessError"
exception="com.haizone.util.BusinessException">
</exception-mapping>
<exception-mapping result="error"
exception="java.lang.Exception">
</exception-mapping>/jsp/clientManager/myShop/uploadResponse.jsp
</global-exception-mappings>--> <action name="myUpload" class="com.haizone.struts.commons.UploadAction">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/bmp,image/png,image/gif,image/pjpeg,image/jpg,image/JPG,image/jpeg,application/vnd.ms-excel,video/quicktime,video/x-msvideo
</param>
<param name="maximumSize">3000009715</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="input">/commons/upload.jsp</result>
<result name="success">/commons/showUpload.jsp</result>
</action>
<action name="client" class="com.haizone.struts.action.test.Client">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/bmp,image/png,image/gif,image/pjpeg,image/jpg,image/JPG,image/jpeg,video/quicktime,video/x-msvideo
</param>
<param name="maximumSize">3000009715</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="input">/commons/uploadClientDemo.jsp</result>
<result name="success">/commons/showUpload.jsp</result>
</action>
</package>
<include file="struts_xml/struts_auth.xml"></include>
<include file="struts_xml/struts_education.xml"></include>
<include file="struts_xml/struts_resource.xml"></include>
<include file="struts_xml/struts_gear.xml"></include>
<include file="struts_xml/struts_plan.xml"></include>
<include file="struts_xml/struts.xml"></include>
<include file="struts_xml/struts_basedata.xml"></include>
<include file="struts_xml/struts_policemange.xml"></include>
<include file="struts_xml/struts_interior.xml"></include>
<include file="struts_xml/struts_service.xml"></include>
<include file="com/hizone/workflow/config/struts_workflow.xml"></include>
</struts>
这样出错
T
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
<url-pattern>*.aaa</url-pattern>
</filter-mapping>还是不行......
window.location.href="<%=pagepath %>/resource/addrequest.aaa 这样还是出404
window.location.href="<%=pagepath %>/resource/addrequest.action 这样可以
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
后缀名的事情过滤器会帮你处理
/* 我试了 .aaa不行 .action可以
struts.properties怎么修改
我的是这样的struts.objectFactory = spring
struts.locale = zh_CN
struts.i18n.encoding = GBK
struts.enable.DynamicMethodInvocation = true
struts.i18n.reload = truestruts.custom.i18n.resources = globalMessages_zh_CN
struts.multipart.saveDir = /tmp
struts.multipart.maxSize=3000009715
struts.action.extension=action我加了个
struts.action.extension=aaa 整个都不行了 - -!
struts.properties里面配置的常量优先struts.xml,
常量只需要配置一个地方就可以了.!
如果你是在struts.properties中配的
在你的struts.properties中写
struts.action.extension=action,aaa
配置多个扩展名
我把struts.action.extension=action,aaa这句删了可以