比如: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中文乱码处理的更多相关文章

  1. 【Spring学习笔记-MVC-16】Spring MVC之重定向-解决中文乱码

    概述 spring MVC框架controller间跳转,需重定向,主要有如下三种: 不带参数跳转:形如:http://localhost:8080/SpringMVCTest/test/myRedi ...

  2. struts2 使用filter解决中文乱码问题

    1.编写fliter的代码 import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChai ...

  3. struts2.1.6存在中文乱码的bug

    如题,后续版本中已解决:可以通过添加filter的方式解决.

  4. 服务器返回中文乱码的情况(UTF8编码 -> 转化为 SYSTEM_LOCALE 编码)

    服务器乱码 转换使用如下方法 入惨{“msg”} -> utf8编码 -> 转化为 SYSTEM_LOCALE 编码 -> 接受转换后的参数 "sEncoding" ...

  5. struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)

    我的前台页是这样的: <body>      <form action="test.action" method="post">     ...

  6. SSH中post提交表单action中文乱码问题

    我的问题对应的解决方案是:web.xml中filter的顺序问题[置顶].需要将编码过滤器放置在所有过滤器之前. 在解决这个问题途中学习到的东西: 解决方案总结(post中文乱码): 前后台编码方式一 ...

  7. struts2 action重定向

    struts2的结果类型: <action name="loginAction" class="com.itheima.action.LoginAction&quo ...

  8. ajax调用,action返回的中文为乱码的解决方案

    原文:ajax调用,action返回的中文为乱码的解决方案 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.c ...

  9. 关于struts2中表单提交时,中文乱码问题的解决

    http://blog.csdn.net/hjw506848887/article/details/8966194 今天写项目时,突然遇到了struts2中表单提交的中文乱码问题,调了好久就是不知道答 ...

随机推荐

  1. 深入了解 WPF Dispatcher 的工作原理(Invoke/InvokeAsync 部分)

    深耕 WPF 开发的各位程序员大大们一定避不开使用 Dispatcher.跨线程访问 UI 当然免不了用到它,将某个任务延迟到当前任务之后执行也会用到它.Dispatcher.Invoke.Dispa ...

  2. 《DSP using MATLAB》示例Example6.18、6.19

  3. Linux驱动开发基础知识

    常用命令 lsmod: list module,将模块列表显示),功能是打印出当前内核中已经安装的模块列表 insmod: install module,安装模块,功能是向当前内核中去安装一个模块,用 ...

  4. 简单安装MySQL(RPM方式)

    本次测试使用一台ip为192.168.2.21的虚拟机 下边的步骤虽然多,但是跟着命令或者复制粘贴命令即可完成操作,并无难点 1.安装准备 MySQL-server-5.6.35-1.linux_gl ...

  5. 总结css的使用技巧

    1. 纯 CSS 的 tooltips 现在的要求是使用纯css在页面上显示一个title,或者图片的描述文字(在鼠标移入图片之后): content,attr() content一般与::befor ...

  6. Ubuntu : 在主机和虚拟机之间传文件

    电脑用的是windows的系统,vmware player打开了一台ubuntu虚拟机,想在它们之间传送文件. 在宿主机上安装FTP文件传输软件 步骤如下: 1.Ubuntu中安装ssh,命令:sud ...

  7. rapidjson的read和write的sample

    头文件 #include "json/document.h" #include "json/prettywriter.h" #include "jso ...

  8. jq 全选

    $(".checkall").change(function(){ if($(this).is(":checked")){ $(".checkchil ...

  9. nginx限制请求之一:(ngx_http_limit_conn_module)模块

    相关文章: <高可用服务设计之二:Rate limiting 限流与降级> <nginx限制请求之一:(ngx_http_limit_conn_module)模块> <n ...

  10. Cassandra Wiki Login JmxSecurity

    JmxSecurity 监控和管理Cassandra