oward" path="/foward.jsp" />
</action>
</action-mappings>
</struts-config>
Action:
public class ExampleAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {
// 得到对应的form
ExampleActionForm eaf = (ExampleActionForm)actionForm;
// 取得输入的test
String test = eaf.getTest();
// 判断并将值放入request
if ("".equals(test)){
request.setAttribute("test","empty");
}else{
request.setAttribute("test",test);
}
// 通过mapping寻找相应的url,返回ActionFoward
return actionMapping.findForward("foward");
}
}
FormBean:
public class ExampleActionForm extends ActionForm {
private String test;
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
}
|