Spring2.5+Struts2+Jpa(Hibernate实现)整合之四
2009-05-15 13:51
639 查看
转载请注明:来自http://blog.csdn.net/M_ChangGong/ 作者:张燕广
改篇主要编写JSP展示页面。
在WebRoot/WEB-INF下创建文件夹pages,在该文件夹下分别创建如下4个JSP页面:
1.学生信息列表页面:studentlist.jsp
其代码如下:
2.添加学生信息页面:addStudent.jsp
其代码如下:
3.学生信息添加结果页面: message.jsp
其代码如下:
4.修改学生信息页面: editStudent.jsp
其代码如下:
修改index.jsp页面,修改后的代码如下:
[b]至此,Spring2.5+Struts2+Jpa(Hibernate实现)的整合工作全部完成。这个小的整合项目实现了CRUD操作,如下图:
[/b]
[b]有兴趣的读者请关注后续Spring2.5+Struts2+Hibernate3整合的系列文章。[/b]
改篇主要编写JSP展示页面。
在WebRoot/WEB-INF下创建文件夹pages,在该文件夹下分别创建如下4个JSP页面:
1.学生信息列表页面:studentlist.jsp
其代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="/struts-tags" prefix="s"%> <!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>学生列表</title> </head> <body> <br> <table border="2px" align="center" width="70%"> <div align="center"><h1><font color="blue">学生信息列表</font></h1></div> <div align="center"><h2><font color="blue">Spring2.5+Struts2+Jpa(Hibernate)实现</font></h2></div> <div align="right"><a href="action_add.action" mce_href="action_add.action">添加学生信息</a></div> <tr> <td style="color:red" mce_style="color:red" align="center">学号</td> <td style="color:red" mce_style="color:red" align="center">姓名</td> <td style="color:red" mce_style="color:red" align="center">操作</td> </tr> <s:iterator value="students"> <tr> <td style="color:blue" mce_style="color:blue" align="center"><s:property value="stuId"/></td> <td style="color:green" mce_style="color:green" align="center"><s:property value="stuName"/></td> <td align="center"> <a href='<s:url action="action_edit"><s:param name="student.stuId" value="stuId" /></s:url>'>修改</a>| <a href='<s:url action="action_delete"><s:param name="student.stuId" value="stuId" /></s:url>'>删除</a> </td> </tr> </s:iterator> </table> </body> </html>
2.添加学生信息页面:addStudent.jsp
其代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>添加学生信息</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" mce_href="styles.css"> --> </head> <h1 style="color:blue" mce_style="color:blue">请添加学生信息</h1> <body> <s:form action="action_save"> 学生姓名:<s:textfield name="student.stuName" value=""/> <s:submit value="提交"/> </s:form> </body> </html>
3.学生信息添加结果页面: message.jsp
其代码如下:
<%@ 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=ISO-8859-1"> <title>添加学生信息结果</title> </head> <body> ${message } <a href="action_list.action" mce_href="action_list.action">查看学生信息</a> </body> </html>
4.修改学生信息页面: editStudent.jsp
其代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>修改学生信息</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" mce_href="styles.css"> --> </head> <h1 style="color:blue" mce_style="color:blue">请修改学生信息</h1> <body> <s:form action="action_save"> 学生姓名:<s:textfield name="student.stuName"/> <s:submit value="提交"/> </s:form> </body> </html>
修改index.jsp页面,修改后的代码如下:
<%@ 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>学生信息管理</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" mce_href="styles.css"> --> </head> <h1>学生信息管理</h1> <body> <a href="student/action_list.action" mce_href="student/action_list.action">查看学生信息</a> </body> </html>
[b]至此,Spring2.5+Struts2+Jpa(Hibernate实现)的整合工作全部完成。这个小的整合项目实现了CRUD操作,如下图:
[/b]
[b]有兴趣的读者请关注后续Spring2.5+Struts2+Hibernate3整合的系列文章。[/b]
相关文章推荐
- Spring2.5+Struts2+Jpa(Hibernate实现)整合之一
- Spring2.5+Struts2+Jpa(Hibernate实现)整合之二
- Spring2.5+Struts2+Jpa(Hibernate实现)整合之三
- Spring2.5+Struts1.3.8+Jpa(Hibernate实现)整合之七
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之一
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之四
- Spring2.5+Struts1.3.8+Jpa(Hibernate实现)整合之八
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之二
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之三
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之五
- Spring2.5+Struts1.3.8+Jpa(Hibernate实现)整合之六
- struts1.x+spring2.5+JPA(hibernate)整合
- Spring3.0 JPA(hibernate3.6实现)整合问题之:java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUni
- hibernate-JPA,struts2,spring三大框架整合的步骤
- [置顶] Spring整合Hibernate实现Spring Data JPA
- GXT2.2+GWT2.4+Struts2+Hibernate3.X+Spring2.5整合完成!!
- Spring3.x_Struts2.x_Hibernate3.x整合之OpenSessionInView的实现
- [置顶] Spring整合Hibernate实现JPA持久化
- Sruts2.1+JPA(Hibernate3.0)+Spring2.5整合详解
- HTTP Status 500 -(struts2整合进spring2.5和hibernate3.3)