下面是请求的html:
<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; } }