- <? xml version="1.0" encoding="ISO-8859-1" ?>
- <! 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 ="productsForm" type ="com.game.products.web.forms.ProductsForm" />
- </ form-beans >
- < global-forwards >
- < forward name ="success" path ="/products/product_success.jsp" />
- < forward name ="failure" path ="/products/product_failure.jsp" />
- </ global-forwards >
- < action-mappings >
- < action path ="/getProducts" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- < forward name ="all" path ="/products/products.jsp" />
- </ action >
- < action path ="/getProduct" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- < forward name ="one" path ="/products/product.jsp" />
- </ action >
- < action path ="/deleteProduct" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- </ action >
- < action path ="/addProductPage" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- < forward name ="add" path ="/products/addproduct.jsp" />
- </ action >
- < action path ="/addProduct" name ="productsForm" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" input ="/product_failure.jsp" >
- </ action >
- < action path ="/updateProduct" name ="productsForm" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" input ="/product_failure.jsp" >
- </ action >
- < action path ="/returnProduct" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- < forward name ="all" path ="/products/products.jsp" />
- </ action >
- < action path ="/queryProducts" type ="org.springframework.web.struts.DelegatingActionProxy" parameter ="method" scope ="request" validate ="false" >
- < forward name ="all" path ="/products/products.jsp" />
- </ action >
- </ action-mappings >
- < message-resources parameter ="com.game.resources.ApplicationResourcesProducts" />
- < plug-in className ="org.apache.struts.validator.ValidatorPlugIn" >
- < set-property property ="pathnames"
- value ="/WEB-INF/struts-validator/validator-rules.xml,/WEB-INF/struts-validator/validation.xml" />
- </ plug-in >
- </ struts-config >
- < bean name ="/getProducts" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- < property name ="pagerService" >
- < ref bean ="pagerService" />
- </ property >
- </ bean >
- < bean name ="/getProduct" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- </ bean >
- < bean name ="/deleteProduct" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- </ bean >
- < bean name ="/addProductPage" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- </ bean >
- < bean name ="/addProduct" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- </ bean >
- < bean name ="/updateProduct" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- </ bean >
- < bean name ="/returnProduct" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- < property name ="pagerService" >
- < ref bean ="pagerService" />
- </ property >
- </ bean >
- < bean name ="/queryProducts" class ="com.game.products.web.actions.ProductsAction" singleton ="false" >
- < property name ="productsService" >
- < ref bean ="productsService" />
- </ property >
- < property name ="pagerService" >
- < ref bean ="pagerService" />
- </ property >
- </ bean >
接着編寫 web.xml ,代碼如下:
- <? xml version="1.0" encoding="GB2312" ?>
- <! 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 > 遊戲軟件管理系統 </ display-name >
- < context-param >
- < param-name > log4jConfigLocation </ param-name >
- < param-value > /WEB-INF/classes/log4j.properties </ param-value >
- </ context-param >
- < context-param >
- < param-name > contextConfigLocation </ param-name >
- < param-value > /WEB-INF/spring-context/applicationContext.xml </ param-value >
- </ context-param >
- < filter >
- < filter-name > Set Character Encoding </ filter-name >
- < filter-class > com.game.commons.SetCharacterEncodingFilter </ filter-class >
- < init-param >
- < param-name > encoding </ param-name >
- < param-value > GB2312 </ param-value >
- </ init-param >
- </ filter >
- < filter-mapping >
- < filter-name > Set Character Encoding </ filter-name >
- < url-pattern > /* </ url-pattern >
- </ filter-mapping >
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
- </listener>
- <listener>
- <listener-class>org.springframework.web.util.Log4jConfigListener </listener-class>
- </listener>
- < 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/struts-config.xml </ param-value >
- </ init-param >
- < init-param >
- < param-name > debug </ param-name >
- < param-value > 3 </ param-value >
- </ init-param >
- < init-param >
- < param-name > detail </ param-name >
- < param-value > 3 </ param-value >
- </ init-param >
- < init-param >
- < param-name > nocache </ param-name >
- < param-value > yes </ 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 > products/index.jsp </ welcome-file >
- </ welcome-file-list >
- < taglib >
- < taglib-uri > struts-bean </ taglib-uri >
- < taglib-location > /WEB-INF/tld/struts-bean.tld </ taglib-location >
- </ taglib >
- < taglib >
- < taglib-uri > struts-html </ taglib-uri >
- < taglib-location > /WEB-INF/tld/struts-html.tld </ taglib-location >
- </ taglib >
- < taglib >
- < taglib-uri > struts-logic </ taglib-uri >
- < taglib-location > /WEB-INF/tld/struts-logic.tld </ taglib-location >
- </ taglib >
- < taglib >
- < taglib-uri > struts-nested </ taglib-uri >
- < taglib-location > /WEB-INF/tld/struts-nested.tld </ taglib-location >
- </ taglib >
- </ web-app >&nb