一个Struts实现分页,增删改查,Tiles,国际化的DEM…

2008-02-23 07:47:54来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

这个DEMO供大家一起探讨学习Struts,因为工作太累,没精力给大家解释实现原理。如果看不懂,没关系。只是说明JSP基础还没有到火候,不要心急,回去强化下JSP Servlet,基础扎实了,自然能够看懂我写的代码。这个DEMO借鉴了网上很多前人的经验,在此一并谢谢。
web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>BookShopMod</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/camel-define.tld</taglib-uri>
<taglib-location>/WEB-INF/camel-define.tld</taglib-location>
</taglib>
</web-app>
Struts-config.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="bookForm" type="com.bookshop.form.BookForm"/>
<form-bean name="operatorForm" type="com.bookshop.form.OperatorForm"/>
<form-bean name="findRecordForm" type="com.bookshop.form.FindRecordForm"/>
</form-beans>
<global-forwards>
<forward name="index" path="/index.jsp"/>
<forward name="browser" path="/show.jsp"/>
<forward name="global_error" path="/error.jsp"/>
</global-forwards>
<action-mappings>
<action input="/show.jsp" name="bookForm" parameter="operator" path="/operatorAction" scope="session" type="com.bookshop.action.OperatorAction" validate="false">
<forward name="operatorok" path="/success.jsp" redirect="true"/>
<forward name="showFirstPage" path="/operatorAction.do?operator=showFirstPage"/>
<forward name="showPreviousPage" path="/operatorAction.do?operator=showPreviousPage"/>
<forward name="showNextPage" path="/operatorAction.do?operator=showNextPage"/>
<forward name="showLastPage" path="/operatorAction.do?operator=showLastPage"/>
<forward name="showAddRecord" path="/editrecord.jsp?operator=addRecord" redirect="true"/>
<forward name="showModifyRecord" path="/editrecord.jsp?operator=modifyRecord"/>
<forward name="showFindRecord" path="/findrecord.jsp" redirect="true"/>
</action>
<action input="/findrecord.jsp" name="findRecordForm" path="/findRecordAction" scope="session" type="com.bookshop.action.FindRecordAction" validate="false"/>
</action-mappings>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:创建Web应用和Struts框架的配置文件

下一篇:Jsp JavaBean循序渐进教程(二)