我的页面和strus2中的常量国际化设置都是utf-8 在请求拦截器中拦截的请求参数中没有乱码
但在action中获得的属性就是乱码 让我很是费解 请各位大侠帮忙指教下
------解决方案--------------------
这时肯定的拉, 建议你用 Filter 处理编码问题. 框架本身并不带Code 处理.
------解决方案--------------------
你如果在Action 处理是没用的, 以为数据已经加载过去了. 下面是Filter 的源码 [code=Java][/code]package com.t56.candy.util;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* Servlet Filter implementation class CodeFilter
*/
public class CodeFilter implements Filter {
/**
* Default constructor.
*/
public CodeFilter() {
// TODO Auto-generated constructor stub
}
/**
* @see Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}
/**
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
// place your code here
// pass the request along the filter chain
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
chain.doFilter(request, response);
}
/**
* @see Filter#init(FilterConfig)
*/
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}