📄 myrequestprocessor.java
字号:
package classmate;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.config.ForwardConfig;
import org.apache.commons.logging.Log;
public class MyRequestProcessor extends RequestProcessor {
public MyRequestProcessor() {}
protected boolean processPreprocess( HttpServletRequest request,
HttpServletResponse response ){
boolean continueProcessing = true;
// Get the name of the remote host and log it
String remoteHost = request.getRemoteHost( );
log.info( "Request from host: " + remoteHost );
// Make sure the host is from one that you expect
if (( remoteHost == null || !remoteHost.startsWith( "127."))){
// Not the localhost, so don't allow the host to access the site
continueProcessing = false;
try{
response.sendRedirect( "/S02_Extend/error.jsp");
}catch( Exception ex ){
log.error("Problem sending redirect from processPreprocess()") ;
}
}
return continueProcessing;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -