struts2 action重定向action中文乱码处理
比如:Action方法productCategorySave()变量message,传递给Action方法productCategoryAdd(),当变量message为中文变量时,要进行编码设置,不然会报中文乱码。
一、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重定向action中文乱码处理的更多相关文章
- 【Spring学习笔记-MVC-16】Spring MVC之重定向-解决中文乱码
概述 spring MVC框架controller间跳转,需重定向,主要有如下三种: 不带参数跳转:形如:http://localhost:8080/SpringMVCTest/test/myRedi ...
- struts2 使用filter解决中文乱码问题
1.编写fliter的代码 import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChai ...
- struts2.1.6存在中文乱码的bug
如题,后续版本中已解决:可以通过添加filter的方式解决.
- 服务器返回中文乱码的情况(UTF8编码 -> 转化为 SYSTEM_LOCALE 编码)
服务器乱码 转换使用如下方法 入惨{“msg”} -> utf8编码 -> 转化为 SYSTEM_LOCALE 编码 -> 接受转换后的参数 "sEncoding" ...
- struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)
我的前台页是这样的: <body> <form action="test.action" method="post"> ...
- SSH中post提交表单action中文乱码问题
我的问题对应的解决方案是:web.xml中filter的顺序问题[置顶].需要将编码过滤器放置在所有过滤器之前. 在解决这个问题途中学习到的东西: 解决方案总结(post中文乱码): 前后台编码方式一 ...
- struts2 action重定向
struts2的结果类型: <action name="loginAction" class="com.itheima.action.LoginAction&quo ...
- ajax调用,action返回的中文为乱码的解决方案
原文:ajax调用,action返回的中文为乱码的解决方案 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.c ...
- 关于struts2中表单提交时,中文乱码问题的解决
http://blog.csdn.net/hjw506848887/article/details/8966194 今天写项目时,突然遇到了struts2中表单提交的中文乱码问题,调了好久就是不知道答 ...
随机推荐
- LeetCode 739. Daily Temperatures
原题链接在这里:https://leetcode.com/problems/daily-temperatures/description/ 题目: Given a list of daily temp ...
- 通过 Windows API 获取鼠标位置等状态信息
#include <graphics.h> #include <stdio.h> void main() { initgraph(, ); // 初始化绘图窗口 HWND hw ...
- c++调用fortran程序中遇到的问题
一.C++动态调用Fortran DLL (1)创建FORTRAN DLL工程,生成forsubs.dll文件供调用. ! forsubs.f90 ! ! FUNCTIONS/SUBROUTINES ...
- 看了redis想一下
redis总结 要想在python中使用redis,要先在本地安装redis,并开启redis-server,然后再导入python的redis包,pip install redis 怎么在Linux ...
- video4linux(v4l)使用摄像头的实例基础教程与体会(转)
1. video4linux基础相关 1.1 v4l的介绍与一些基础知识的介绍 I.首先说明一下video4linux(v4l). 它是一些视频系统.视频软件.音频软 ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料(下)
转载:http://www.jianshu.com/p/b73b6953e849 该资源的github地址:Qix <Statistical foundations of machine lea ...
- emacs之开始就加载tag
~/emacsConfig/original-tags.el (setq tags-table-list ' ( "~/emacsConfig/etags/muduo" " ...
- golang里面检测对象是否实现了接口的方法
写法有点怪异,记一下吧 _, implemented := this.delegate.(IGenTcpServerDelegate) if implemented { this.delegate.G ...
- 队列之blah集合
做了一个NOI上面的问题,叫blah集合,以a为基数,则2x+1和3x+1都在集合中,且集合中全部元素都由此计算得来.a∈[1,50],问升序排列后第n(n∈[1,1000000])个元素是多少.以输 ...
- [转]自己做 Visual Studio 2013 代码折叠插件
本文代码来自:https://msdn.microsoft.com/zh-cn/library/ee197665.aspx 第一步.引用 -> 程序集 -> 扩展 里找到对应 .dll 添 ...