在前一篇文章的基础上,修改一部分即可(在此只是简单介绍)

struts.xml页面

在原来的基础之上

action的name="*_*"  class="包名.{1}" method="{2}"

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- 国际化 -->
<constant name="struts.custom.i18n.resources" value="zr"></constant> <!-- user表的通配符增删改查 -->
<package name="aa" namespace="/user" extends="struts-default">
<action name="*_*" class="com.zr.{1}" method="{2}">
<result name="show">/show.jsp</result>
<result name="add" type="redirectAction">Struts2Text_showstuent?ye=1</result>
<result name="deletee" type="redirectAction">Struts2Text_showstuent?ye=1</result>
<result name="toupdate">/update.jsp</result>
<result name="update" type="redirectAction">Struts2Text_showstuent?ye=1</result>
</action>
</package> <!-- class10表的通配符增删改查 -->
<package name="bb" namespace="/class" extends="struts-default">
<action name="*_*" class="com.zr.{1}" method="{2}">
<result name="show">/Classshow.jsp</result>
<result name="add" type="redirectAction">ClassStruts2Text_showstuent?ye=1</result>
<result name="deletee" type="redirectAction">ClassStruts2Text_showstuent?ye=1</result>
<result name="toupdate">/Classupdate.jsp</result>
<result name="update" type="redirectAction">ClassStruts2Text_showstuent?ye=1</result>
</action>
</package> </struts>

add.jsp页面

将原来的

<form action="user/add.action" >   改为

<form action="user/Struts2Text_add" >

 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'add.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> <script type="text/javascript" src="layer/layer.js"></script>
<script type="text/javascript">
function add(a){
a.submit();
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
parent.ReloadData();
parent.layer.close(index);
} </script> </head> <body>
<form action="user/Struts2Text_add" >
<input type="hidden" name="id">
<input type="hidden" name="method" value="add">
<input type="text" name="username" placeholder=" 请输入姓名"><br/>
<input type="text" name="password" placeholder=" 请输入密码"><br/>
<input type="button" onclick="javascript:add(this.form)" value="确定添加"><br/>
</form>
</body>
</html>

index.jsp页面

对38以及39行代码进行修改

第二行为引入struts标签库   <s:  >  </s:  >

30-39行代码均有国际化的体现  也是与之前代码相比较修改的地方

 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<STYLE type="text/css">
a{
text-decoration: none;
color: black;
}
</STYLE>
</head>
<body>
<s:text name="userName"></s:text> <input type="text" placeholder="请输入用户名"><br/>
<s:text name="password"></s:text> <input type="text" placeholder="请输入密码"><br/>
<s:text name="welcomeInfo">
<s:param>郭艺华</s:param>
<s:param>大哥</s:param>
</s:text>
<button> <s:text name="login"></s:text></button><br/>
………………………………………………………………………………………………………………………………………………………………………………………………………<br/>
<a href="user/Struts2Text_showstuent?ye=1"><s:text name="user"></s:text></a><br/>
<a href="class/ClassStruts2Text_showstuent?ye=1"><s:text name="class"></s:text></a>
</body>
</html>

show.jsp页面

主要修改90-104行的分页代码   因为每一次翻页都需要用到show方法

也就是通配符的修改

 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'show.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="layer/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
<script type="text/javascript">
function func10() {
//iframe层
layer.open({
type: 2,
title: 'layer mobile页',
closeBtn: 1, //不显示关闭按钮
shadeClose: true,
shade: 0.8,
area: ['380px', '90%'],
content: 'add.jsp' //iframe的url
});
} function func11(id) {
//iframe层
layer.open({
type: 2,
title: 'layer mobile页',
closeBtn: 1, //不显示关闭按钮
shadeClose: true,
shade: 0.8,
area: ['380px', '90%'],
content: 'user/Struts2Text_toupdate?id='+id //iframe的url
});
} function ReloadData(){
window.location.reload();
}
</script> <style type="text/css">
a{
text-decoration: none;
color: black;
}
</style> </head> <body> <table border="1" bordercolor="gray" >
<tr>
<th>编号</th>
<th>姓名</th>
<th>密码</th>
<th>删除</th>
<th>修改</th>
</tr>
<c:forEach items="${list}" var="a">
<tr>
<td>${a.id}</td>
<td>${a.username}</td>
<td>${a.password}</td>
<td> <a href="user/Struts2Text_deletee?id=${a.id}">删除</a></td>
<td> <a href="javascript:func11(${a.id})">修改</a></td>
</tr>
</c:forEach>
</table> <c:if test="${param.ye>1}">
<a href="user/Struts2Text_showstuent?ye=1">首页</a>
</c:if>
<c:if test="${param.ye>1}">
<a href="user/Struts2Text_showstuent?ye=${param.ye-1}">上一页</a>
</c:if>
<c:forEach begin="1" end="${count}" varStatus="a">
<a href="user/Struts2Text_showstuent?ye=${a.index }">${a.index }</a>
</c:forEach>
<c:if test="${param.ye<count}">
<a href="user/Struts2Text_showstuent?ye=${param.ye+1}">下一页</a>
</c:if>
<c:if test="${param.ye<count}">
<a href="user/Struts2Text_showstuent?ye=${count}">尾页</a>
</c:if> <a href="javascript:func10()"> 添加 </a><br/> </body>
</html>

然后是代码笔记,在这里就不放源代码了

关于通配符的(未国际化之前)

(通配符加国际化)

index.jsp页面

struts.xml文件配置   国际化  只需要加一句话

以下为properties文件  命名规范根据语言缩写来

具体可以在Internet选项进行查看

properties文件打开样式

以上就是简单的通配符以及国际化的简单介绍

仅供参考

仅供记录

2017-08-1020:23:24

struts2增删改查---layer---iframe层---通配符---国际化的更多相关文章

  1. struts2增删改查---layer---iframe层

    在这里写一下struts2中的简单的增删改查 struts.xml中的配置 <?xml version="1.0" encoding="UTF-8" ?& ...

  2. struts2增删改查

    1.导入相关的依赖:struts.自定义标签库 配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xm ...

  3. Struts2增删改查(自己思路理解)

    1:查询所有: DAO层:把所有的信息都放到list集合中.然后返回. public List<Employee> getEmployees(){ return new ArrayList ...

  4. 反射实现增删改查(DAO层)——查询数据

    先贴出代码,后续补充自己的思路.配置文件.使用方式: /** * * 数据查询 * */ @Override public List<?> queryObject(List<Map& ...

  5. 反射实现增删改查(DAO层)——修改数据

    先贴出代码,后续补充自己的思路.配置文件.使用方式: /** * * 修改数据 * */ @Override public void updateObject(Object object, Strin ...

  6. 反射实现增删改查(DAO层)——删除数据

    先贴出代码,后续补充自己的思路.配置文件.使用方式: /** * * 删除数据 */ @Override public void deleteObject(List<Map<String, ...

  7. 反射实现增删改查(DAO层)——插入数据

    先贴出代码,后续补充自己的思路.配置文件.使用方式: /** * 插入数据 */ @Override public void addObject(Object object, String table ...

  8. 权限管理系统之LayUI实现页面增删改查和弹出层交互

    由于对LayUI框架不太熟悉,昨天抽空看了下LayUI的文档,今天在网上找了使用LayUI进行增删改查相关内容,自己照葫芦画了个瓢,画瓢部分不是很难,主要是下午遇到了一个弹出层的问题耗时比较久. 同一 ...

  9. Struts2+Spring+Hibernate实现员工管理增删改查功能(一)之ssh框架整合

    前言        转载请标明出处:http://www.cnblogs.com/smfx1314/p/7795837.html 本项目是我写的一个练习,目的是回顾ssh框架的整合以及使用.项目介绍: ...

随机推荐

  1. mkdirs自动创建文件夹

    //保存路径 如file路径是E:\filer\a.jpg File toSaveFile=new File("filePath"); if(toSaveFile!=null){ ...

  2. ps命令注意事项

    1.ps命令由于历史原因,版本比较多,主要分为三种版本 1)Unix风格的版本,命令参数加单横线.比如ps -ef 2)BSD风格的版本,命令参数前不加任何横线.比如ps aux 3)GNU风格的版本 ...

  3. python核心数据结构之字典

    ![](http://images2015.cnblogs.com/blog/1182370/201706/1182370-20170628210759774-266944364.jpg) [TOC ...

  4. 遇到build的问题

    可以打开C/C++BUILD里面把build直接改成cmd,cmd   path是有的

  5. 插入多行数据的时候,一个insert插入多行

    如:insert into t_users(a,b,c)value('1','2','3'),('3','4','5'),('6','7','8') ('1','2','3'),('3','4','5 ...

  6. java变量的分类与初始化

    2017/6/25 首先学习java最权威的就是官方的文档了,今天从头读了文档,把一些小细节理清楚. 变量 Java语言里的变量分以下4类: 1. Instance Variables: (Non-S ...

  7. 不用EF框架,完成完美实体映射,且便于维护!(AutoMapper,petapoco)

    最近,需要搭建一个新项目,在需求分析时确定数据库中需要创建多个存储过程.所以如果还是用原来EF框架生成ADO.net实体模型的话,不利于修改. 主要是解决以下两个问题: 1.比如前端需要一个值,如果存 ...

  8. 数据结构(C语言版)顺序栈相关算法的代码实现

    这两天完成了栈的顺序存储结构的相关算法,包括初始化.压栈.出栈.取栈顶元素.判断栈是否为空.返回栈长度.栈的遍历.清栈.销毁栈.这次的实现过程有两点收获,总结如下: 一.清楚遍历栈的概念 栈的遍历指的 ...

  9. web项目直接在浏览器上访问不需要带.jsp,直接ip地址加项目名 在web.xml里配置

    web.xml最上方 <welcome-file-list> <welcome-file> /view/login.jsp </welcome-file> < ...

  10. java IO之 编码 (码表 编码 解码 转换流)

    编码 什么是编码? 计算机中存储的都是二进制,但是要显示的时候,就是我们看到的却可以有中国 ,a  1 等字符 计算机中是没有存储字符的,但是我们却看到了.计算机在存储这些信息的时候,根据一个有规 则 ...