码迷,mamicode.com
首页 > 其他好文 > 详细

struts2.xml 配置文件入门

时间:2015-12-10 19:46:15      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:struts2 入门 xml配置

<?xml version="1.0" encoding= "UTF-8" ?>

<!DOCTYPE struts PUBLIC

     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

     "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>


     <!-- DMI 动态方法调用 !后跟action里的方法面 -->

     <constant name= "struts.enable.DynamicMethodInvocation" value ="true" />

     <!-- 修改本页面可不用重新加载 tomcat,上传文件处理时需要将value=false -->

     <constant name ="struts.devMode" value="true" />


     <!-- name可以随意起 namespace 区分模块不要随意改动,如果改成/book 在browser地址栏项目明后添加/book/对应的action -->

     <package name ="default" namespace="/" extends= "struts-default">

           <action name ="index">

               <result >/index.jsp </result >

           </action >

           <!-- method后为默认跳转方法 -->

           <action name ="test" class="com.cola.struts.Test" method= "show">

               <result >/test.jsp </result >

           </action >


           <!-- 加上通配符* action后直接跟方法名 -->

           <!-- <action name="book*" class="com.cola.struts.BookAction" method="{1}"

              > <result name="success">/{1}. jsp</result> </action> -->

           <!-- *的顺序对应{}里的数字 -->

           <!-- <action name="*_*" class="com.cola.struts.{1}Action" method="{2}"

              > <result name="success">/{1}_{2}.jsp</result> </action> -->


           <action name ="book" class= "com.cola.struts.BookAction">

               <result name= "success">/book_value.jsp</result >

           </action >

           <action name ="user" class= "com.cola.struts.UserAction">

               <result name= "success">/book_value.jsp</result >

           </action >

     </package >


     <package name ="user" namespace="/user" extends= "default">

           <action name ="index">

               <result >/test.jsp </result >

           </action >

     </package >

</struts>


struts2.xml 配置文件入门

标签:struts2 入门 xml配置

原文地址:http://icola.blog.51cto.com/5412204/1721689

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!