struts2解决get和post方式中文乱码
来源:互联网 发布:淘宝大学课程培训 编辑:程序博客网 时间:2024/05/16 15:26
1.首先在struts.xml文件里设置<constant name="struts.i18n.encoding" value="utf-8"/>
2.添加如下拦截器。拦截所有参数带中文的请求
2.添加如下拦截器。拦截所有参数带中文的请求
public String intercept(ActionInvocation invocation) throws Exception {HttpServletRequest request= (HttpServletRequest) invocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);if(request.getMethod().equalsIgnoreCase("post"))return invocation.invoke();Map<String, Object> params=invocation.getInvocationContext().getParameters();Set<Entry<String, Object>> entries=params.entrySet();for(Iterator<Entry<String, Object>> itor=entries.iterator();itor.hasNext();){Entry<String, Object> entry=itor.next();if(entry.getValue().getClass()==String[].class){String[] strs=(String[]) entry.getValue();for(int i=0;i<strs.length;i++){strs[i]=new String(strs[i].getBytes("ISO-8859-1"), "utf-8");}}}return invocation.invoke();
}
0 0
- struts2解决get和post方式中文乱码
- 过滤器解决get和post方式提交的中文乱码
- GET&POST方式解决中文乱码问题
- get post 中文请求乱码解决方式
- Struts2中解决POST请求和GET请求中的中文乱码问题
- Struts2中解决POST请求和GET请求中的中文乱码问题
- post/get解决中文乱码
- struts2默认能解决get和post提交方式的乱码问题吗?
- 解决用jquery的get或者post提交方式提交到struts2中的action中文乱码问题
- 解决struts2以GET方式提交表单中文乱码问题
- 解决struts2以GET方式提交表单中文乱码问题
- 解决struts2以GET方式提交表单中文乱码问题
- Servlet中文乱码原因 解决 Get 和 Post 和客户端
- Servlet中文乱码原因 解决 Get 和 Post 和客户端
- get和post方式提交中文乱码问题
- 解决Get和Post请求中中文乱码问题
- httpclient get和post,中文乱码已解决
- 解决Get和post请求中中文乱码问题
- Java反射机制应用
- Leetcode 198 House Robber 抢劫最大金额
- 软件开发工具(五)——开发与发展
- 【asp】有效防止网站留言板出现垃圾留言/评论实现思路_ASP教程
- Redmine与TestLink的整合
- struts2解决get和post方式中文乱码
- ArcGIS engine调用GP服务说明
- js实现返回上一页功能
- 【asp】ASP wsImage组件添加水印的实用代码_ASP教程
- libcurl实现断点续传
- javascript的prototype经典使用场景
- 使用HttpClient方式请求网络
- Material Design之TextInputLayout使用示例
- 黑马程序员---OC类方法