struts2 url 传参 中文乱码 的一种解决办法
来源:互联网 发布:淘宝静物摄影 编辑:程序博客网 时间:2024/05/16 03:53
<a href="test.action?userName=张三">请点击</a>
上面的 userName 的值是中文,传到 action 后会变乱码。
因为url传中文实际开发中并不是很常用,一般都是表单传中文。
因此,如果不想去改项目和tomcat的配置的话,可以如下做法:
public class TestAction extends ActionSupport { private String userName; public void setUserName(String userName) throws UnsupportedEncodingException { this.userName = new String(userName.getBytes("iso-8859-1"), "utf-8"); } @Override public String execute() throws Exception { return SUCCESS; }}
直接修改set方法,struts2绑定数据时,马上转换为utf-8即可。
阅读全文
0 0
- struts2 url 传参 中文乱码 的一种解决办法
- 在struts2种解决url中文乱码的方法(其中一种方法)
- JCREATOR3.0 中文乱码的一种解决办法
- JCREATOR3.0 中文乱码的一种解决办法
- JCREATOR3.0中文乱码的一种解决办法
- Struts2中文乱码解决办法
- struts2 中文乱码解决办法
- struts2中文乱码解决办法
- struts2 中文乱码解决办法
- Struts2中文乱码解决办法
- struts2的中文参数乱码解决办法
- Struts2 Action中文乱码问题的解决办法
- Struts2 Action中文乱码问题的解决办法
- Struts2 Action中文乱码问题的解决办法
- Struts2 Action中文乱码问题的解决办法
- Struts2 Action中文乱码问题的解决办法
- 一种另类的解决URL中文乱码问题
- Apache 中文乱码解决方案(很特殊的一种解决办法)
- spring-事务传播特性
- Jmeter之逻辑控制器(Logic Controller)
- 设计模式C++实现(7)——外观模式、组合模式
- MVC从视图传参到Controller几种方式
- Spring和hibernate集成写API进行CRUD操作
- struts2 url 传参 中文乱码 的一种解决办法
- 为图片添加水印的源码
- Django模型model
- 【Linux环境搭建】——nginx安装教程
- ETL工具—kettle使用之三
- JDK8的安装与配置-Linux之Debian系统
- C++11支持使用or代替||符号
- C# WPF 如何禁止窗口拖到屏幕边缘自动最大化
- 20171013 JSP中page和pageContext的区别