Struts1.2中文过滤

1.在util包下新建一个类Encoding 实现超类RequestProcessor (org.apache.struts.action.RequestProcessor)
2.alt+shift+S----->实现方法----->选择倒数第三个processPreprocess方法
3.写上request.setCharacterEncoding("utf-8");并抛出异常

具体代码如下:

/*****
**方法如下
**/

protected boolean processPreprocess(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
	}


4.在struts-config.xml里加上
<controller processorClass="com.svse.struts.util.Encoding"></controller>

猜你喜欢

转载自shangxun.iteye.com/blog/1935366
今日推荐