struts2 action重定向action中文乱码处理
2013-11-11 17:06
344 查看
比如:Action方法productCategorySave()变量message,传递给Action方法productCategoryAdd(),当变量message为中文变量时,要进行编码设置,不然会报中文乱码。
一、Action方法productCategorySave()
二、Action方法productCategoryAdd()
三、Action配置
四、显示变量message
---------------------------------------------------------------------------------
Blog:http://www.cnblogs.com/linjiqin/
Hadoop交流群(250363249)、Java+Oracle交流群(158560018)
题外话:
本人来自铁观音的发源地——泉州安溪,有需要正宗安溪铁观音的友友欢迎Q我:416501600。
一、Action方法productCategorySave()
/** * 商品分类保存 * * @return */ @Action("productCategorySave") public String productCategorySave() { laf.setMessage("信息。"); return "productCategoryAdd"; }
二、Action方法productCategoryAdd()
/** * 商品分类添加 * * @return */ @Action("productCategoryAdd") @Powers( { @Power(PowerConsts.PRODUCTMODULE_PRODUCTCATEGORY_LIST) }) public String productCategoryAdd() { if(StringUtils.isNotBlank(laf.getMessage())){ //对message变量进行转码 laf.setMessage(Utils.convertUtf8(laf.getMessage())); } return "productCategoryAdd"; }
三、Action配置
@Results(value = { @Result(name = "productCategoryAdd", location = "/content/goods/product_category_add.jsp"), @Result(name = "productCategorySave", location = "/productCategoryAdd.htm", //${message}可以用具体值代替,如:params={"message", "信息。"}; //${message}为productCategorySave()方法的变量, params={"message", "${message}"}, type="redirectAction"), })
四、显示变量message
<c:if test="${message!=null}"><font color="red">${message}</font></c:if>
---------------------------------------------------------------------------------
Blog:http://www.cnblogs.com/linjiqin/
Hadoop交流群(250363249)、Java+Oracle交流群(158560018)
题外话:
本人来自铁观音的发源地——泉州安溪,有需要正宗安溪铁观音的友友欢迎Q我:416501600。
相关文章推荐
- Struts2中action重定向跳转到jsp参数中带有中文(乱码解决的方案)
- Struts2的action中处理JSONP方式提交的中文乱码问题:
- struts2中redirectAction方式 重定向带参数/中文参数乱码
- action接收到来自jsp页面的请求时出现中文乱码问题处理方法
- 解决Struts2中表单提交到action时的中文乱码
- struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)
- struts2中jsp页面表单提交到action中文乱码问题
- Ajax融合struts2过程中,action类回传给客户端中文数据出现问号乱码的解决办法
- Struts2重定向时,OGNL异常(中文乱码)解决方法。
- [整理]Struts2 中文乱码处理
- [forwarding] Struts2中action接收中文参数为乱码解决方法
- struts2 表单提交 action 中文乱码
- Struts1.X与Struts2.X中文乱码处理
- struts2 jsp提交到action出现中文乱码问题
- struts2中jsp页面表单提交到action中文乱码问题
- [置顶] struts2 action 接收中文乱码
- struts2重定向中文参数乱码有关问题
- 学习struts2建bbs总结四:解决jsp/action中文传值乱码问题
- struts2重定向时传递参数的实现!以及传递参数为中文时的乱码问题解决!
- Struts2 学习笔记 —— 10 —— Action接收参数时的中文乱码问题