※ActionMapping、RequestProcessor
public class MyActionMapping extends ActionMapping {}
public class MyRequestProcessor extends RequestProcessor {
@Override
protected ActionMapping processMapping(HttpServletRequest req, HttpServletResponse res, String action)
throws IOException {
ActionMapping mapping = super.processMapping(req, res, action);
if (mapping instanceof MyActionMapping) {
if (!req.getMethod().equals("POST")) {
mapping = null;
}
}
return mapping;
}
}
※mapping = null 網頁會變成空的,我使用 findForward 沒效
※struts-config
<form-beans> <form-bean name="ooo" type="controller.LoginActionForm"> <form-property name="username" type="java.lang.String" /> <form-property name="password" type="java.lang.String" /> </form-bean> </form-beans> <action-mappings> <action path="/xxx" type="controller.LoginAction" name="ooo" scope="request" validate="true" input="/index.jsp" className="mapping.MyActionMapping"> <forward name="success" path="/s.jsp" /> <forward name="fail" path="/f.jsp" /> </action> </action-mappings> <controller processorClass="listener.MyRequestProcessor" contentType="text/html" nocache="true" locale="false" />
※增加 controller 標籤,和在 action 標籤增加 className 屬性