zoukankan      html  css  js  c++  java
  • Struts_ActionWildcard_通配符配置

    使用通配符,将配置量降到最低

    不过,一定要遵守“约定由于配置”的原则

    struts2.xml

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE struts PUBLIC
     3     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
     4     "http://struts.apache.org/dtds/struts-2.3.dtd">
     5 
     6 <struts>
     7     <constant name="struts.configuration.xml.reload" value="true"/>
     8     <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
     9     
    10     <!-- namespace 必须 "/" 开头 -->
    11     <package name="actions" namespace="/actions" extends="struts-default">
    12         <action name="Student_add" class="com.bjsxt.struts2.action.TestAction" method="test">
    13             <result>/test.jsp</result>
    14         </action>
    15         
    16         <action name="Student*" class="com.bjsxt.struts2.action.StudentAction" method="{1}">
    17             <result>/student{1}_success.jsp</result>
    18         </action>
    19         
    20         <action name="*_*" class="com.bjsxt.struts2.action.{1}Action" method="{2}">
    21             <result>/{1}_{2}_success.jsp</result>
    22         </action>
    23     </package>
    24     
    25 </struts>

    StudentAction

     1 package com.bjsxt.struts2.action;
     2 
     3 import com.opensymphony.xwork2.ActionSupport;
     4 
     5 public class StudentAction extends ActionSupport{
     6 
     7     private static final long serialVersionUID = -8074753294134724983L;
     8     
     9     public String delete(){
    10         return SUCCESS;
    11     }
    12     
    13     public String add(){
    14         return SUCCESS;
    15     }
    16 
    17 }

    CourseAction

     1 package com.bjsxt.struts2.action;
     2 
     3 import com.opensymphony.xwork2.ActionSupport;
     4 
     5 public class CourseAction extends ActionSupport{
     6 
     7     private static final long serialVersionUID = -602409660355584918L;
     8 
     9     public String add(){
    10         return SUCCESS;
    11     }
    12     
    13     public String delete(){
    14         return SUCCESS;
    15     }
    16 }
    View Code

    TeacherAction

     1 package com.bjsxt.struts2.action;
     2 
     3 import com.opensymphony.xwork2.ActionSupport;
     4 
     5 public class TeacherAction extends ActionSupport{
     6     
     7     private static final long serialVersionUID = -7951798648480925065L;
     8 
     9     public String add(){
    10         return SUCCESS;
    11     }
    12     
    13     public String delete(){
    14         return SUCCESS;
    15     }
    16     
    17 }
    View Code

    TestAction

    package com.bjsxt.struts2.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class TestAction extends ActionSupport{
    
        private static final long serialVersionUID = -8074753294134724983L;
        
        public String test(){
            return SUCCESS;
        }
    
    }

    链接: http://pan.baidu.com/s/1miDgviS 密码: m24y

  • 相关阅读:
    Ogre中的旋转变换问题 Vector3 , Quaternion,matrix
    OIS几个重要的类的使用
    Ogre中的向量Vector3的成员方法
    用Ogre画三角形
    pitch yaw roll 的区别
    OGRE中用到的设计模式
    OGRE体系结构(类的继承关系)
    OGRE教程SceneNode, Entity, SceneManager and Get start 的讲解
    Asp.net Mvc 身份验证、异常处理、权限验证(拦截器)
    Asp.Net Mvc2 OA工作流设计思路
  • 原文地址:https://www.cnblogs.com/ShawnYang/p/6670601.html
Copyright © 2011-2022 走看看