1 在struts-config.xml中添加
<controller processorClass="sofix_site.CharsetProcessor"/>
2 新建一个类 sofix_site.CharsetProcessor 继承 RequestProcessor
package sofix_site;
import org.apache.struts.action.RequestProcessor;
import javax.servlet.http.*;
import java.io.*;
//做中文处理的RequestProcessor类
public class CharsetProcessor extends RequestProcessor {
public CharsetProcessor() {
}
public boolean processPreprocess(HttpServletRequest request,HttpServletResponse response)
{
try {
request.setCharacterEncoding("GBK");
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
return true;
}
}