- 浏览: 214821 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (397)
- j2se (28)
- nio (3)
- 易错点 (3)
- 面试ssh (9)
- ssh整合 (11)
- jbpm+spring (2)
- js (15)
- 高级技术 (59)
- swing (3)
- 数据库 (16)
- hibernate (18)
- spring (19)
- 开发网站知识点 (9)
- jbpm (4)
- json (5)
- 设计模式 (22)
- 自定义标签 (1)
- j2ee (9)
- lucene (3)
- cahce (11)
- maven (5)
- html5 (1)
- 多数据源 (10)
- 页面聊天 (9)
- 富客户端 (1)
- android (13)
- aop+拦截器+jms (13)
- 框架整合 (1)
- 非阻塞io (24)
- 暂时不看 (13)
- webservice (3)
- oracle (3)
- 算法 (4)
- 协程 (2)
- netty (1)
- 爬虫 (0)
- 高级基础 (1)
- JVM调优总结 (12)
- 知识点技巧 (1)
- REST (0)
- 基础 io (2)
- dubbo (8)
- 线程 (1)
- spring源码 (2)
- git (1)
- office (2)
最新评论
-
sjzcmlt:
,写的挺好的啊
一个完整的负载均衡的例子 . -
他大姨妈:
网上大部分例子都是直接通过IdleStateHandler来实 ...
Netty的超时机制 心跳机制
一 运行环境: XP3+Myeclipse6.6+Tomcat7
二 项目框架版本号:Struts2 version: 2.2.1.1,Spring version: 3.1,Hibernate version:3.6,在Hibernate下有个jar为:javassist-3.12.0.GA.jar,在这个示例中用的是:javassist-3.7.ga.jar,这二个在这个示例中都可以用,没问题,一般原则用新版本的
项目所用jar文件如下图
三 具体实现如下:
1 配置文件:
Web.xml
Xml代码
Struts2.xml文件如下:
struts.xml代码
applicationContext.xml配置文件如下:
jdbc.properties属性文件如下:
Properties代码
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.username=liuzd
jdbc.password=liuzd
log4j.properties属性文件如下:
Properties代码
[%-5p][%c{1}] - %m%n
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.db=org.apache.log4j.FileAppender
log4j.appender.db.File=${s2sh.root}/WEB-INF/logs/ssh.log
log4j.appender.db.Append=true
log4j.appender.db.layout=org.apache.log4j.PatternLayout
log4j.appender.db.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] - %m%n
2 Java代码如下:
A WEB层:
BaseAction Code:
UserAction Code:
Service层:
UserService Code:
UserServiceImpl Code:
Entity层:
User Code:
DAO层:
UserDAO Code:
UserDAOImpl Code:
3 JSp代码如下:
Login.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Sign On</title>
</head>
<body>
<s:form action="userAction">
<s:textfield key="user.username"/>
<s:password key="user.password" />
<s:submit/>
</s:form>
</body>
</html>
Success.jsp,fail.jsp
Jsp代码
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
</head>
<body>
<s:property value="message"/><br>
<a href="${pageContext.request.contextPath}">返回</a>
<s:debug></s:debug>
</body>
</html>
User.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>用户信息</title>
</head>
<body>
<s:form action="userAction!editUser.action">
<input type="hidden" name="action" value='<s:property value="action"/>'/>
<s:property value="message"/><br>
<s:if test="user.id != null">
<s:property value="user.id"/>,<s:property value="user.username"/>,
<s:property value="user.age"/>,<s:property value="user.sex"/>,
<s:property value="user.address"/>,<s:property value="user.password"/>,
<s:property value="#request.myname"/>,<s:property value="#session.mysex"/>
</s:if>
<br>
<table>
<tr>
<td>
<s:hidden name="user.id"/>
<s:textfield label="姓名" name="user.username"/>
</td>
</tr>
<tr>
<td>
<s:textfield label="年龄" name="user.age"/>
</td>
</tr>
<tr>
<td>
<s:select label="性别" name="user.sex"
list="#{ 1:'男', 2: '女', 3: '未知'}"
listKey="key"
listValue="value"
></s:select>
</td>
</tr>
<tr>
<td>
<s:textfield label="密码" name="user.password" size="50"/>
</td>
</tr>
<tr>
<td>
<s:textfield label="地址" name="user.address"/>
</td>
</tr>
<tr>
<td align="right">
<s:submit vlaue="保存"/>
</td>
</tr>
</table>
</s:form>
<br>
<s:debug></s:debug>
<br>
<a href="${pageContext.request.contextPath}">返回主页</a><br>
<s:a href="userAction!userList.action">返回显示</s:a>
</body>
</html>
UserList.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<html>
<head>
<title>用户集合</title>
</head>
<body>
<table width="50%" border="1" cellpadding="1" align="center">
<thead>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>地址</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!--
<s:iterator value="#request.userList" status="status" >
<tr align="center">
<td><s:property value="username"/></td>
<td><s:property value="age"/></td>
<td><s:property value="sex"/></td>
<td><s:property value="address"/></td>
<td>
<s:a href="userAction!addUser.action">添加</s:a> | <s:a href="userAction!loadUser.action?user.id=%{id}">编辑</s:a> |
<a href="<s:url action="userAction!delUser.action"><s:param name="user.id" value="id"/></s:url>">删除</a>
</td>
</tr>
</s:iterator>
-->
<c:forEach items="${requestScope.userList}" var="user">
<tr align="center">
<td>${user.username}</td>
<td>${user.age}</td>
<td>${user.sex eq 1 ? "男" : user.sex eq 2 ? "女" : "未知"}</td>
<td>${user.address}</td>
<td>
<a href="${pageContext.request.contextPath}/userAction!addUser.action">添加</a> |
<a href="${pageContext.request.contextPath}/userAction!loadUser.action?user.id=${user.id}">编辑</a> |
<a href="${pageContext.request.contextPath}/userAction!delUser.action?user.id=${user.id}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
<a href="${pageContext.request.contextPath}">返回</a>
<br>
</body>
</html>
4 Oracle.sql
Sql代码
1.create table USERS
2.(
3. id VARCHAR2(50) not null,
4. username VARCHAR2(50),
5. age NUMBER,
6. sex VARCHAR2(1),
7. address VARCHAR2(200),
8. password VARCHAR2(20)
9.);
10.alter table USERS add constraint PKUID primary key (ID);
11.
12.insert into USERS (ID, USERNAME, AGE, SEX, ADDRESS, PASSWORD, ROWID)
13.values ('001', 'spring', 25, '1', '成都市', 'spring', '');
14.commit;
二 项目框架版本号:Struts2 version: 2.2.1.1,Spring version: 3.1,Hibernate version:3.6,在Hibernate下有个jar为:javassist-3.12.0.GA.jar,在这个示例中用的是:javassist-3.7.ga.jar,这二个在这个示例中都可以用,没问题,一般原则用新版本的
项目所用jar文件如下图
三 具体实现如下:
1 配置文件:
Web.xml
Xml代码
Struts2.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <context-param> <param-name>webAppRootKey</param-name> <param-value>s2sh.root</param-value> </context-param> <context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath*:applicationContext.xml </param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>60000</param-value> </context-param> <context-param> <param-name>log4jExposeWebAppRoot</param-name> <param-value>false</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <filter> <filter-name> encodingFilter </filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name> encoding </param-name> <param-value> UTF-8 </param-value> </init-param> </filter> <filter-mapping> <filter-name> encodingFilter </filter-name> <url-pattern> /* </url-pattern> </filter-mapping> <filter> <filter-name> openSessionInView </filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name> openSessionInView </filter-name> <url-pattern> /* </url-pattern> </filter-mapping> <filter> <filter-name> struts2 </filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name> struts2 </filter-name> <url-pattern> /* </url-pattern> </filter-mapping> <welcome-file-list> <welcome-file> index.jsp </welcome-file> </welcome-file-list> </web-app>
struts.xml代码
<?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> <package name="user" extends="struts-default"> <action name="userAction" class="u"> <result name="success">success.jsp</result> <result name="userList">userList.jsp</result> <result name="fail">fail.jsp</result> <result name="user">user.jsp</result> </action> </package> </struts>
applicationContext.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:annotation-config /> <context:component-scan base-package="com.liuzd.s2sh" /> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>com.liuzd.s2sh.entity</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.Oracle10gDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="format_sql">true</prop> </props> </property> </bean> <!-- 让spring管理sessionFactory的加一种方法 ,就是不删除hibernate.cfg.xml文件; <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:config> <aop:pointcut id="bussinessService" expression="execution(public * com.liuzd.s2sh.service.*.*(..))" /> <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" /> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="edit*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> </beans>
jdbc.properties属性文件如下:
Properties代码
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.username=liuzd
jdbc.password=liuzd
log4j.properties属性文件如下:
Properties代码
[%-5p][%c{1}] - %m%n
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.db=org.apache.log4j.FileAppender
log4j.appender.db.File=${s2sh.root}/WEB-INF/logs/ssh.log
log4j.appender.db.Append=true
log4j.appender.db.layout=org.apache.log4j.PatternLayout
log4j.appender.db.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] - %m%n
2 Java代码如下:
A WEB层:
BaseAction Code:
import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import org.apache.struts2.interceptor.SessionAware; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class BaseAction extends ActionSupport implements SessionAware{ private static final long serialVersionUID = 1L; public void setSession(Map<String, Object> sessionMap) { } protected Map<String,Object> getSession(){ return (Map<String,Object>)ActionContext.getContext().getSession(); } protected HttpServletRequest getRequest(){ return ServletActionContext.getRequest (); } }
UserAction Code:
import java.util.List; import javax.annotation.Resource; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import com.liuzd.s2sh.entity.User; import com.liuzd.s2sh.service.UserService; @Component("u") @Scope("prototype") public class UserAction extends BaseAction { private static final long serialVersionUID = 1L; private UserService userService = null; private String message = null; private User user = null; private String action = null; public String getAction() { return action; } public void setAction(String action) { this.action = action; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } @Override public String execute() throws Exception { System.out.println("user: "+user); User dbUser = this.userService.checkUserExits(user); if (null != dbUser) { message = "用户: " + user.getUsername() + "登录成功"; System.out.println(message); getSession().put("sessionUser",dbUser); return userList(); } message = "用户: " + user.getUsername() + "登录失败"; return "fail"; } public String loadUser(){ action = "update"; message = "编辑用户信息"; User loadUser = new User(); loadUser.setId(user.getId()); user = this.userService.getUserByUid(loadUser); this.getRequest().setAttribute("myname","天涯海角"); this.getSession().put("mysex", "男"); System.out.println("loaduser: "+user); return "user"; } public String addUser(){ action = "add"; return "user"; } public String saveUser(){ this.userService.addUser(user); return "user"; } public String delUser(){ action = "del"; this.userService.delUser(user); return userList(); } public String editUser(){ System.out.println("action: "+action+",编辑用户: "+user); if("update".equals(action)){ this.userService.editUser(user); }else if("add".equals(action)){ saveUser(); } return userList(); } public String userList(){ List<User> userList = this.userService.getUserList(); System.out.println("usersize: "+userList.size() + ",user: " + userList.get(0)); getRequest().setAttribute("userList", userList); return "userList"; } public UserService getUserService() { return userService; } @Resource public void setUserService(UserService userService) { this.userService = userService; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }
Service层:
UserService Code:
import java.util.List; import com.liuzd.s2sh.entity.User; public interface UserService { public User checkUserExits(User user) throws Exception; public void addUser(User user); public void editUser(User user); public void delUser(User user); public List<User> getUserList(); public User getUserByUid(User user); }
UserServiceImpl Code:
import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Component; import com.liuzd.s2sh.dao.UserDAO; import com.liuzd.s2sh.entity.User; import com.liuzd.s2sh.service.UserService; @Component("userService") public class UserServiceImpl implements UserService { private UserDAO userDao = null; public UserDAO getUserDao() { return userDao; } @Resource public void setUserDao(UserDAO userDao) { this.userDao = userDao; } public User checkUserExits(User user) throws Exception { return this.userDao.getUserByUserIdAndUserNameExits(user); } @Override public void delUser(User user) { this.userDao.delUser(user); } @Override public User getUserByUid(User user) { return this.userDao.getUser(user); } @Override public List<User> getUserList() { return this.userDao.finUserAll(); } @Override public void addUser(User user) { String id =String.valueOf(new java.util.Random().nextInt(100)); //user.setId(id); System.out.println("添加: "+user); this.userDao.saveUser(user); } @Override public void editUser(User user) { this.userDao.updateUser(user); } }
Entity层:
User Code:
@Entity @Table(name="users") public class User { private String id = null; private String username = null; private String password = null; private String address = null; private String sex = null; private Integer age = null; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } /* * 适合ID为int,short,long的情况 * @Id @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ_USER") @SequenceGenerator(name="SEQ_USER",sequenceName="S_USER",allocationSize=1) */ @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid") public String getId() { return id; } public void setId(String id) { this.id = id; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } @Override public String toString() { return "name: " + username + ",password: " + password+",sex: " + sex + ",age: " + age+",address: " + address + ",id: " + id; } }
DAO层:
UserDAO Code:
import java.util.List; import com.liuzd.s2sh.entity.User; public interface UserDAO { /** * 检查用户是否存在 * */ public User getUserByUserIdAndUserNameExits(User user); public void saveUser(User user); public void updateUser(User user); public User getUser(User user); public void delUser(User user); public List<User> finUserAll(); }
UserDAOImpl Code:
import java.util.List; import javax.annotation.Resource; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Component; import com.liuzd.s2sh.dao.UserDAO; import com.liuzd.s2sh.entity.User; @Component("userDao") public class UserDAOImpl implements UserDAO { private HibernateTemplate hibernateTemplate; public HibernateTemplate getHibernateTemplate() { return hibernateTemplate; } @Resource public void setHibernateTemplate(HibernateTemplate hibernateTemplate) { this.hibernateTemplate = hibernateTemplate; } public User getUserByUserIdAndUserNameExits(User user) { List<User> users = hibernateTemplate.find("from User u where u.username = '" + user.getUsername() + "' and u.password='"+user.getPassword()+"'"); if (users != null && users.size() > 0) { return users.get(0); } return null; } @Override public void saveUser(User user) { this.hibernateTemplate.save(user); } @Override public void delUser(User user) { User delUser = getUser(user); this.hibernateTemplate.delete(delUser); } @Override public List<User> finUserAll() { return this.hibernateTemplate.find("from User"); } @Override public User getUser(User user) { return this.hibernateTemplate.load(User.class,user.getId()); } @Override public void updateUser(User user) { this.hibernateTemplate.update(user); } }
3 JSp代码如下:
Login.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Sign On</title>
</head>
<body>
<s:form action="userAction">
<s:textfield key="user.username"/>
<s:password key="user.password" />
<s:submit/>
</s:form>
</body>
</html>
Success.jsp,fail.jsp
Jsp代码
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
</head>
<body>
<s:property value="message"/><br>
<a href="${pageContext.request.contextPath}">返回</a>
<s:debug></s:debug>
</body>
</html>
User.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>用户信息</title>
</head>
<body>
<s:form action="userAction!editUser.action">
<input type="hidden" name="action" value='<s:property value="action"/>'/>
<s:property value="message"/><br>
<s:if test="user.id != null">
<s:property value="user.id"/>,<s:property value="user.username"/>,
<s:property value="user.age"/>,<s:property value="user.sex"/>,
<s:property value="user.address"/>,<s:property value="user.password"/>,
<s:property value="#request.myname"/>,<s:property value="#session.mysex"/>
</s:if>
<br>
<table>
<tr>
<td>
<s:hidden name="user.id"/>
<s:textfield label="姓名" name="user.username"/>
</td>
</tr>
<tr>
<td>
<s:textfield label="年龄" name="user.age"/>
</td>
</tr>
<tr>
<td>
<s:select label="性别" name="user.sex"
list="#{ 1:'男', 2: '女', 3: '未知'}"
listKey="key"
listValue="value"
></s:select>
</td>
</tr>
<tr>
<td>
<s:textfield label="密码" name="user.password" size="50"/>
</td>
</tr>
<tr>
<td>
<s:textfield label="地址" name="user.address"/>
</td>
</tr>
<tr>
<td align="right">
<s:submit vlaue="保存"/>
</td>
</tr>
</table>
</s:form>
<br>
<s:debug></s:debug>
<br>
<a href="${pageContext.request.contextPath}">返回主页</a><br>
<s:a href="userAction!userList.action">返回显示</s:a>
</body>
</html>
UserList.jsp
Jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<html>
<head>
<title>用户集合</title>
</head>
<body>
<table width="50%" border="1" cellpadding="1" align="center">
<thead>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>地址</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!--
<s:iterator value="#request.userList" status="status" >
<tr align="center">
<td><s:property value="username"/></td>
<td><s:property value="age"/></td>
<td><s:property value="sex"/></td>
<td><s:property value="address"/></td>
<td>
<s:a href="userAction!addUser.action">添加</s:a> | <s:a href="userAction!loadUser.action?user.id=%{id}">编辑</s:a> |
<a href="<s:url action="userAction!delUser.action"><s:param name="user.id" value="id"/></s:url>">删除</a>
</td>
</tr>
</s:iterator>
-->
<c:forEach items="${requestScope.userList}" var="user">
<tr align="center">
<td>${user.username}</td>
<td>${user.age}</td>
<td>${user.sex eq 1 ? "男" : user.sex eq 2 ? "女" : "未知"}</td>
<td>${user.address}</td>
<td>
<a href="${pageContext.request.contextPath}/userAction!addUser.action">添加</a> |
<a href="${pageContext.request.contextPath}/userAction!loadUser.action?user.id=${user.id}">编辑</a> |
<a href="${pageContext.request.contextPath}/userAction!delUser.action?user.id=${user.id}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
<a href="${pageContext.request.contextPath}">返回</a>
<br>
</body>
</html>
4 Oracle.sql
Sql代码
1.create table USERS
2.(
3. id VARCHAR2(50) not null,
4. username VARCHAR2(50),
5. age NUMBER,
6. sex VARCHAR2(1),
7. address VARCHAR2(200),
8. password VARCHAR2(20)
9.);
10.alter table USERS add constraint PKUID primary key (ID);
11.
12.insert into USERS (ID, USERNAME, AGE, SEX, ADDRESS, PASSWORD, ROWID)
13.values ('001', 'spring', 25, '1', '成都市', 'spring', '');
14.commit;
发表评论
-
2 springmvc+hibernate
2014-10-25 10:16 497springMVC-servlet.xml < ... -
1 spingmvc搭建
2014-10-25 22:39 568web.xml <?xml version=& ... -
JTA事物
2014-10-18 10:43 461applicationContext.xml <b ... -
junit4
2014-06-16 10:01 531test hibernate private static S ... -
spring4+mybaits3整合—项目Demo
2014-06-17 09:40 1412项目下载地址:http://pan.baidu.com/s/1 ... -
struts2.2+spring3.1+hibernate3.2整合方法三
2014-04-19 15:15 564beans.xml <?xml version=&quo ... -
struts2.0.14+spring2.5+hibernate3.2整合方法二
2014-04-19 14:45 434struts2.0.14+spring2.5+hibernat ... -
struts2.0.14+spring2.5+hibernate3.2整合方法一
2014-04-19 14:37 643struts2.0.14+spring2.5+hibernat ... -
spring+hibernate+JTA 分布式事务的例子 .
2014-04-11 21:32 1020对于横跨多个Hibernate SessionFacotry的 ... -
spring mvc+hibernate框架(转)
2014-04-04 15:07 590弃用了struts,用spring mvc ...
相关推荐
在"struts2.2+spring3.05+hibernate3.6整合"项目中,我们将看到如何将这三个框架协同工作,实现一个基于MySQL数据库的应用程序。Struts2.2版本提供了更好的Action类支持和拦截器功能,Spring3.05加强了AOP(面向切面...
在实际开发中,开发者会将这三个框架的jar包整合到项目中,例如在描述中提到的"struts2+spring2.5+hibernate3.3",可能表示的是一个使用了Struts2.2、Spring3.0和Hibernate3.3的项目配置。文件名称列表中的"struts2+...
本示例将重点介绍如何在Struts2.2、Hibernate3.6和Spring3.1集成环境下实现分页功能。 首先,Struts2是Action-based的MVC框架,它提供了一种灵活的方式来处理用户请求,并通过拦截器机制增强了应用的可扩展性。...
Struts2.1、Hibernate3.1和Spring2.5是经典的Java企业级开发框架组合,简称SSH。这个整合项目主要是为了实现基本的数据操作:增加(Create)、删除(Remove)、修改(Update)和查询(Retrieve),也就是CRUD操作。...
Struts2、Spring2.5和Hibernate3.2是Java Web开发中经典的三大框架,它们的整合使用在过去的许多年里被广泛应用于企业级应用系统。这个完整的项目提供了从开发环境到运行环境的所有必要组件,包括数据库脚本,使得...
Struts2、Spring4和Hibernate4是Java Web开发中的三大主流框架,它们分别负责MVC模式中的表现层、业务层和服务层。这个最新的项目系统整合了这三个框架,旨在提供一个高效、灵活且易于维护的开发环境。下面将详细...
Struts2.2、Hibernate3.3和Spring2.5.6是三个经典的Java企业级开发框架,它们的整合能够实现MVC模式的高效应用,提供了数据持久化、业务逻辑控制以及模型视图分离等功能。在这个简单的CRUD案例中,我们将看到如何在...
Struts1.2、Spring2.5和Hibernate3.2是经典的Java企业级开发框架组合,它们各自在应用程序的不同层次上发挥着重要作用。Struts1.2是一个MVC(Model-View-Controller)框架,主要负责处理用户界面与业务逻辑之间的...
Struts2、Spring和Hibernate是Java Web开发中的三...以上就是关于“Struts2+Spring2.5+Hibernate3.2整合示例”的主要知识点,这个整合实例涵盖了Java Web开发中的重要技术,对于开发者来说,深入学习和实践将非常有益。
Struts2.2、Spring2.5.5和Hibernate3.4是经典的Java Web开发框架组合,被称为SSH(Struts2、Spring、Hibernate)或SSH2。这个组合在过去的十几年中广泛应用于企业级应用开发,提供了强大的MVC(模型-视图-控制器)...
Struts1、Spring2和Hibernate2是Java Web开发中的三个重要框架,它们分别负责MVC模式中的表现层、业务层和服务层。这个整合例子旨在展示如何将这三个框架协同工作,以构建一个完整的Java Web应用程序。 Struts1是...
【开发Web购物网站(Struts1.2+Hibernate3.1+Spring2.0)整合案例详细解析】 在构建Web购物网站时,选择合适的框架对于项目的成功至关重要。本案例中,我们采用Struts1.2、Hibernate3.1和Spring2.0这三大经典Java框架...
Struts2、Spring和Hibernate是Java Web开发中的三大框架,它们的整合应用广泛用于构建复杂的Web应用程序,如本例中的图书馆管理系统。这个系统实现了用户登录和注册功能,并且提供了对书籍表的操作,包括增、删、改...
这里我们详细探讨一下"Struts2.3.x+Spring3.1.x+Hibernate4.1整合工程"的相关知识点。 **Struts2** 是一个基于MVC设计模式的Java Web框架,它主要用于处理HTTP请求和响应,提供了强大的表单验证、国际化支持以及...
Struts2.3、Hibernate4.1和Spring3.1是Java开发中经典的SSH(Spring、Struts和Hibernate)框架组合,它们各自负责应用程序的不同层面,以实现高效、灵活的Web应用开发。在这个"Struts2.3+Hibernate4.1+Spring3.1 SSH...
在本文中,我们将详细介绍Struts2.0+Spring2.0+Hibernate3.1的登录及增删改查功能的完整演示示例。这个示例适合初学者进行学习。首先,需要了解这三种技术:Struts2、Spring和Hibernate,它们都是Java EE开发中不可...
Struts2.1.8+Spring2.5.6+Hibernate3.3.2是经典的Java Web开发框架组合,常被称为SSH。这三个框架协同工作,为开发者提供了强大的模型-视图-控制器(MVC)架构支持,使得企业级应用的开发更加高效和模块化。 Struts...
SSH整合,即Struts、Spring和Hibernate三大框架的集成,是Java Web开发中常见的技术栈。这个整合项目中包括了MySQL数据库的相关驱动,意味着它将使用MySQL作为后端数据存储。接下来,我们将深入探讨SSH整合的关键...