Struts_ActionWildcard_通配符配置
使用通配符,将配置量降到最低
不过,一定要遵守“约定由于配置”的原则
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>
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/> <!-- namespace 必须 "/" 开头 -->
<package name="actions" namespace="/actions" extends="struts-default">
<action name="Student_add" class="com.bjsxt.struts2.action.TestAction" method="test">
<result>/test.jsp</result>
</action> <action name="Student*" class="com.bjsxt.struts2.action.StudentAction" method="{1}">
<result>/student{1}_success.jsp</result>
</action> <action name="*_*" class="com.bjsxt.struts2.action.{1}Action" method="{2}">
<result>/{1}_{2}_success.jsp</result>
</action>
</package> </struts>
StudentAction
package com.bjsxt.struts2.action;
import com.opensymphony.xwork2.ActionSupport;
public class StudentAction extends ActionSupport{
private static final long serialVersionUID = -8074753294134724983L;
public String delete(){
return SUCCESS;
}
public String add(){
return SUCCESS;
}
}
CourseAction
package com.bjsxt.struts2.action;
import com.opensymphony.xwork2.ActionSupport;
public class CourseAction extends ActionSupport{
private static final long serialVersionUID = -602409660355584918L;
public String add(){
return SUCCESS;
}
public String delete(){
return SUCCESS;
}
}
TeacherAction
package com.bjsxt.struts2.action;
import com.opensymphony.xwork2.ActionSupport;
public class TeacherAction extends ActionSupport{
private static final long serialVersionUID = -7951798648480925065L;
public String add(){
return SUCCESS;
}
public String delete(){
return SUCCESS;
}
}
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
Struts_ActionWildcard_通配符配置的更多相关文章
- 01_6_Struts_ActionWildcard_通配符配置
01_6_Struts_ActionWildcard_通配符配置 1.Struts_ActionWildcard_通配符配置 1.1配置struts.xml文件 <package name=&q ...
- Struts2的通配符配置方式
Struts2的Action类很有意思,你可以使用3种方式来实现具体的Action类: 让你的Action类继承自ActionSupport类(项目中最常用这种方式,因为ActionSupport类中 ...
- 使用通配符配置action
建立struts2wildcard项目,此实例基本仿照前面前面第7点的实例改写而成.为了使用通配符,只需要改写配置文件即可.此实例未使用通配时的配置文件如下: <action name=&quo ...
- 配置typeAliasesPackage支持通配符包路径扫描
mybatis的xml文件中需要写类的全限定名,较繁琐,可以配置自动扫描包路径给类配置别名,两种配置方式. 方式一: mybatis-config.xml中配置 <typeAliases> ...
- Struts2-Action接受参数方式、method属性使用及通配符的配置
一.Action接受参数的方式 1.属性方式接收 首先编写一个用于上传参数的页面 <%@ page contentType="text/html;charset=UTF-8" ...
- 五 Action访问方法,method配置,通配符(常用),动态
1 通过method配置(有点low) 建立前端JSP:demo4.jsp <%@ page language="java" contentType="text/h ...
- Struts2中重定向和请求转发配置
struts2中默认跳转为dispatcher请求转发 只能往jsp转发,跳转action报404 重定向 设置为redirect ,可以是jsp也可以是action <!--同一个包下的act ...
- sphinx 配置sphinx.conf
sphinx的配置文件是在配置的时候最容易出错的了: 基本概念: source:数据源,数据是从什么地方来的. index:索引,当有数据源之后,从数据源处构建索引.索引实际上就是相当于一个字典检索. ...
- Struts2中通配符
1.Struts2中通配符可通过请求的url路径来确定包.类.方法.返回值名. 如 <action name="*_*_*_*" class="cn.javass. ...
随机推荐
- SSKeychain的使用 钥匙串
一.首先要理解keychain与userdefaults的区别: 1.keychain是将数据加密后存储在本地,更安全.路径:Library/Application Support/iPhone Si ...
- DataGrip 使用--方法-..../
tip1: 关键字 自动 大写--
- 简单理解php的socket连接
socket建立套接的过程图: 首先了解socket 几个主要函数: socket的关键函数1: socket_create($net参数1,$stream参数2,$protocol参数3) 作用:创 ...
- CPU和微架构的概念
CPU是什么: 中央处理器(CPU,Central Processing Unit)是一块超大规模的集成电路,是一台计算机的运算核心(Core)和控制核心( Control Unit). 它的功能主要 ...
- 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_运行时解析类型引用
public sealed class Program{ public static void Main() { System.Console.WriteLine("Hi"); } ...
- echarts图调用多个接口
html: <div id="sentimentMain1" style="width:960px;height:500px;margin:20px auto;&q ...
- 笔记_简明Python教程_Byte_of_Python
1. 局部变量.全局变量 局部变量: x = 50 def func(x): x = 2 print('Change local x to',x) func(x) print('x is still' ...
- vue-踩过的坑
1)引入组件时路径一定要是./ or ../开头 import Goback from './public/goback.vue' 2)这类输入框绑定的值不是:value 不是 :value 不然数据 ...
- Vue循环中多个input绑定指定v-model
Vue.js中提供了v-model可以双向绑定表单元素,这个方法可以非常方便的获得输入的值,但是有时候表单元素需要循环生成,在循环中要怎样获得指定输入框的值呢 这里介绍两种,一种是v-for中循环生成 ...
- 使用bootstrap创建上传文件
1.导入样式,注意顺序 <!-- bootstrap样式 --> <link rel="stylesheet" href="/static/bootst ...