Struts2 通配符使用
来源:互联网 发布:什么值得买 类似 知乎 编辑:程序博客网 时间:2024/05/18 00:01
Struts2通配符的使用可以在同一个Action中实现一个类别的(如学生管理) 增,删,改,查 方便项目后期的维护和查看。
1.页面请求
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="alladd.action">添加数据</a><br/>
<a href="allupdate_updateSuccess.action">修改数据</a><br/>
<a href="alldelete.action">删除数据</a><br/>
<a href="allquery.action">查询数据</a><br/>
</body>
</html>
2.Action配置
import com.opensymphony.xwork2.ActionSupport;
import com.sun.org.apache.regexp.internal.recompile;
public class AllAction extends ActionSupport{
public String add(){
System.out.println("执行添加");
return "success";
}
public String update(){
System.out.println("执行修改");
return "updateSuccess";
}
public String delete(){
System.out.println("执行删除");
return "success";
}
public String query(){
System.out.println("执行查询");
return "success";
}
}
3.请求的控制转发struts.xml, <action name="all*" class="action.AllAction" method="{1}">其中all后面的*等于
上面jsp <a href="alladd.action">添加数据</a><br/>中alladd.action all后面的add。 {1}表示第一个通配符也就是add。
method="{1}"表示跳转到AllAction中对应的方法中
<?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>
<package name="mypackage" extends="struts-default">
<action name="all*" class="action.AllAction" method="{1}">
</action>
</package>
</struts>
- struts2通配符的使用
- struts2通配符的使用
- struts2通配符的使用
- struts2 使用通配符
- struts2通配符的使用
- struts2—使用通配符
- struts2的通配符使用
- struts2:通配符的使用
- Struts2中使用通配符
- struts2中通配符使用
- struts2 2.5使用通配符
- Struts2 通配符使用
- struts2通配符的使用
- Struts2配置文件中使用通配符
- Struts2配置文件中使用通配符
- Struts2使用8 -- 通配符映射
- Struts2 使用通配符定义action
- struts2--配置文件通配符的使用
- 通过 maven中引入oracle驱动
- UEditor V1.4.3控制文件压缩
- bzoj 2697 特技飞行 贪心
- redis服务安装卸载命令
- Android事件分发机制的图片总结(上)
- Struts2 通配符使用
- HTML&CSS设计与构建网站(css)
- GPU版本不同时,cmakelist要注意修改
- 有状态对象和无状态对象
- C++进阶—>易错知识点随笔
- JS中变量类型及运算的一些知识点总结
- 需要学习的知识点
- poj3009之深度优先搜索 dfs解法
- dorado5 之一eclipse配置dorado5插件