配置文件
</action-mappings> <controller processorClass="com.silmon.struts.action.MyProcessor"></controller>
MyProcessor.java
public class MyProcessor extends RequestProcessor {
protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) {
/*
* String remoteIp = request.getRemoteHost();
*
* if (remoteIp.startsWith("127")) { System.out.println("您的Ip为:" + remoteIp); System.out.println("不可以访问本站"); return true; } else { System.out.println("Continue..."); return false;
* }
*
*/
try {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}