struts1_MappingDispatchAction
2426 ワード
リクエストhtmlは次のとおりです.
次にstruts-config.xmlファイル:
次に、リクエストされたjavaファイルを示します.
<html:link action="/addbook"> </html:link>
<html:link action="/deletebook"> </html:link>
<html:link action="/updatebook"> </html:link>
<html:link action="/findbook"> </html:link>
次にstruts-config.xmlファイル:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<action-mappings>
<action path="/addbook" type="cn.itcast.web.action.BookAction2" parameter="add"/>
<action path="/updatebook" type="cn.itcast.web.action.BookAction2" parameter="update"/>
<action path="/findbook" type="cn.itcast.web.action.BookAction2" parameter="find"/>
<action path="/deletebook" type="cn.itcast.web.action.BookAction2" parameter="delete"/>
</action-mappings>
</struts-config>
次に、リクエストされたjavaファイルを示します.
public class BookAction2 extends MappingDispatchAction {
public ActionForward add(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
System.out.println("add....");
return null;
}
public ActionForward update(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
System.out.println("udpate....");
return null;
}
public ActionForward delete(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
System.out.println("delete....");
return null;
}
public ActionForward find(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
System.out.println("find....");
return null;
}
}