关于struts2的xml中<result type="redirect">参数问题

本文记录了一个在Struts框架中使用&lt;result&gt;标签进行页面重定向时遇到的问题,即使用redirect类型传递参数时,特定参数名flag会导致重定向失败。通过将flag改为showflag解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       

 

        今天做项目的时候,遇到一个奇葩问题。我需要在struts的xml中的<action>的<result>中配置type="redirect",同时需要传参进去。试了老半天,我的别的参数都好着,就flag参数不好,纠结死了都快。后来,突然想想,改一下,说不定是什么关键字之类的,就把flag改成了showflag了,竟然奇迹般的好了!!!特此记录。有类似问题的大家还是不要直接写flag比较好。尴尬

 

 

 

<result name="success" type="redirect">test.action?id=${id}&amp;showflag=${showflag}</result>
<result name="error">/error.jsp</result>

注:我的showflag在对应的action当中是声明过的,在方法中request.setAttribute进去的,在前台js接收用${showflag}。
<?xml version="1.0" encoding="UTF-8" ?> <!-- /* * $Id: struts-plugin.xml 722219 2008-12-01 20:41:26Z musachy $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <bean class="com.inc.sbu.view.FreeMarkerPageFilter" static="true" optional="true"/> <constant name="struts.ognl.allowStaticMethodAccess" value="true" /> <constant name="struts.convention.relative.result.types" value="freemarker,dispatcher"/> <constant name="struts.convention.action.mapAllMatches" value="true"/> <constant name="struts.convention.package.locators" value="web,action" /> <constant name="struts.convention.default.parent.package" value="yk-default"/> <constant name="struts.convention.result.path" value="/pages"/> <constant name="struts.convention.result.flatLayout" value="true"/> <constant name="struts.i18n.encoding" value="gbk" /> <constant name="struts.i18n.reload" value="false" /> <constant name="struts.devMode" value="false" /> <constant name="struts.serve.static.browserCache" value="false"/> <constant name="struts.configuration.xml.reload" value="false" /> <constant name="struts.custom.i18n.resources" value="globalMessages" /> <constant name="struts.freemarker.manager.classname" value="customFreemarkerManager" /> <constant name="struts.multipart.saveDir" value="/tmp"/> <constant name="struts.multipart.maxSize" value="1000000000" /> <constant name="struts.ui.theme" value="simple"/> <constant name="struts.action.extension" value="xhtml,,json" /> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package name="yk-default" extends="struts-default"> <result-types> <result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult"/> <result-type name="json" class="org.apache.struts2.json.JSONResult"/> </result-types> <interceptors> <interceptor class="com.inc.sbu.struts.AuctionInterceptor" name="auctionInterceptor"/> <interceptor class="com.inc.sbu.struts.TokenInterceptor" name="incTokenInterceptor"/> <interceptor class="com.inc.sbu.struts.WorkFlowInterceptor" name="incFlowInterceptor"/> <interceptor class="com.inc.sbu.util.FileUploadInterceptor" name="fileUploadInterceptor"/> <interceptor class="com.inc.sbu.struts.ClewInterceptor" name="clewInterceptor"/> <interceptor-stack name="bidStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> <interceptor-ref name="servletConfig"/> <interceptor-ref name="prepare"/> <interceptor-ref name="profiling"/> <interceptor-ref name="staticParams"/> <interceptor-ref name="actionMappingParams"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*,^struts\..*</param> </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="auctionInterceptor"/> </interceptor-stack> <interceptor-stack name="subStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> <interceptor-ref name="servletConfig"/> <interceptor-ref name="i18n"/> <interceptor-ref name="prepare"/> <interceptor-ref name="chain"/> <interceptor-ref name="profiling"/> <interceptor-ref name="scopedModelDriven"/> <interceptor-ref name="fileUploadInterceptor"/> <interceptor-ref name="fileUpload"/> <interceptor-ref name="checkbox"/> <interceptor-ref name="staticParams"/> <interceptor-ref name="actionMappingParams"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*,^struts\..*</param> </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="validation"> <param name="excludeMethods">input,inputxy,back,cancel,browse</param> </interceptor-ref> <interceptor-ref name="clewInterceptor"> <param name="excludeMethods">login,loginManager,logout,index</param> </interceptor-ref> <interceptor-ref name="incTokenInterceptor"/> </interceptor-stack> </interceptors> <default-interceptor-ref name="subStack"/> <global-results> <result name="invalid.token">/pages/error/repeat-submit.jsp</result> <result name="clew" type="dispatcher">/pages/clew.jsp</result> <result name="manage-clew" type="dispatcher">/pages/manage-clew.jsp</result> <result name="auction-clew" type="dispatcher">/pages/auction-clew.jsp</result> <result name="syserror" type="dispatcher">/pages/error.jsp</result> <result name="validerror" type="dispatcher">/pages/error.jsp</result> <result name="frontpurviewerror" type="dispatcher">/pages/error/frontpurviewerror.jsp</result> <result name="frontloginerror" type="dispatcher">/pages/error/frontpurviewerror.jsp</result> <result name="fronterror" type="dispatcher">/pages/error/frontticketerror.jsp</result> <result name="filenotfound" type="dispatcher">/pages/error/filenotfound.jsp</result> <result name="login" type="redirect">/login</result> <result name="adminLogin" type="dispatcher">/login.jsp</result> <result name="login" type="redirect">/login</result> <result name="entran" type="redirect">/entran</result> <!-- <result name="adminLogin" type="dispatcher">/login.jsp</result> --> <result name="auctionAdminError" type="redirect">/auction/adminLogin</result> <result name="auctionActorError" type="redirect">/auction/login</result> </global-results> </package> <!-- Overwrite Convention --> </struts> 我现在需要重写fileUpload,即不再使用fileUpload的拦截器,需要怎么配置
最新发布
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值