Struts、Spring、hibernate的整合
2012-11-04 23:14
393 查看
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 指定spring的配置文件,默认从web根目录寻找配置文件,我们可以通过spring提供的classpath:前缀指定从类路径下寻找 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
<?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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:component-scan base-package="com.isoftstone"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="org.gjt.mm.mysql.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/isoftstone?useUnicode=true&characterEncoding=UTF-8"/>
<property name="user" value="root"/>
<property name="password" value="520123412"/>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="1"/>
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize" value="1"/>
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize" value="300"/>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="60"/>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="5"/>
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
<property name="idleConnectionTestPeriod" value="60"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>com/isoftstone/bean/Employee.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=false
</value>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--使用基于注解方式配置事务 -->
<tx:annotation-driven transaction-manager="txManager"/>
</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- 默认的视图主题 -->
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.objectFactory" value="spring" />
<package name="employee" namespace="/employee" extends="struts-default">
<action name="list" class="employeeAction">
<result name="list">/WEB-INF/page/employee.jsp</result>
</action>
<action name="manage_*" class="employeeManageAction" method="{1}">
<result name="add">/WEB-INF/page/employeeAdd.jsp</result>
<result name="message">/WEB-INF/page/message.jsp</result>
</action>
</package>
</struts>
package com.isoftstone.service;
import java.util.List;
import com.isoftstone.bean.Employee;
public interface EmployeeService {
public void save(Employee employee);
public void update(Employee employee);
public Employee find(String username);
public void delete(String... usernames);
public List<Employee> list();
}
package com.isoftstone.bean;
public class Employee {
private String username;
private String password;
private Gender gender=Gender.MAN;
public Employee() {
super();
}
public Employee(String username, String password) {
super();
this.username = username;
this.password = password;
}
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;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
}
package com.isoftstone.bean;
public enum Gender {
MAN,WOMEN;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.isoftstone.bean">
<class name="Employee">
<id name="username" length="20"/>
<property name="password" length="20" not-null="true"/>
<property name="gender" not-null="true" length="5">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">com.isoftstone.bean.Gender</param>
<!-- 12为java.sql.Types.VARCHAR常量值,即保存枚举的字面值到数据库。如果不指定type参数,保存枚举的索引值(从0开始)到数据库-->
<param name="type">12</param>
</type>
</property>
</class>
</hibernate-mapping>
package com.isoftstone.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.isoftstone.bean.Employee;
import com.isoftstone.service.EmployeeService;
@Service @Transactional
public class EmployeeServiceBean implements EmployeeService{
@Resource SessionFactory factory;
public void delete(String... usernames) {
for(String username : usernames){
factory.getCurrentSession().delete(factory.getCurrentSession().load(Employee.class, username));
}
}
@Transactional(propagation=Propagation.NOT_SUPPORTED)
public Employee find(String username) {
return (Employee)factory.getCurrentSession().get(Employee.class, username);
}
@SuppressWarnings("unchecked")
@Transactional(propagation=Propagation.NOT_SUPPORTED)
public List<Employee> list() {
return factory.getCurrentSession().createQuery("from Employee").list();
}
public void save(Employee employee) {
factory.getCurrentSession().persist(employee);
}
public void update(Employee employee) {
factory.getCurrentSession().merge(employee);
}
}
package junit.test;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.isoftstone.bean.Employee;
import com.isoftstone.bean.Gender;
import com.isoftstone.service.EmployeeService;
public class EmployeeTest {
private static EmployeeService employeeService;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
ApplicationContext act = new ClassPathXmlApplicationContext("beans.xml");
employeeService = (EmployeeService)act.getBean("employeeServiceBean");
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void save(){
employeeService.save(new Employee("liming", "123456"));
}
@Test
public void update(){
Employee employee = employeeService.find("xxxx");
employee.setGender(Gender.WOMEN);
employeeService.update(employee);
}
@Test
public void delete(){
employeeService.delete("liming");
}
@Test
public void list(){
List<Employee> ems = employeeService.list();
for(Employee em: ems)
System.out.println(em.getPassword());
}
@Test
public void find(){
Employee em = employeeService.find("liming");
System.out.println(em.getPassword());
}
}
package com.isoftstone.action;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import com.isoftstone.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
@Controller // employeeAction
public class EmployeeAction {
@Resource EmployeeService employeeService;
public String execute(){
ActionContext.getContext().put("employees", employeeService.list());
return "list";
}
}
package com.isoftstone.action;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.isoftstone.bean.Employee;
import com.isoftstone.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
@Controller @Scope("prototype")
public class EmployeeManageAction {
@Resource EmployeeService employeeService;
private Employee employee;
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public String addUI(){
return "add";
}
public String add(){
employeeService.save(employee);
ActionContext.getContext().put("message", "±£´æ³É¹¦");
return "message";
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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">
</head>
<body>
ONGL:
<br/>
<s:iterator value="#request.employees">
<s:property value="username"/> ,<s:property value="password"/>, <s:property value="gender"/><br/>
</s:iterator>
<br/>
<a href="<s:url action="manage_addUI" namespace="/employee"/>">员工添加</a>
<br/>
JSTL/EL:
<br/>
<c:forEach items="${employees}" var="employee">
${employee.username}, ${employee.password}, ${employee.gender}<br/>
</c:forEach>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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">
</head>
<body>
<s:form action="manage_add" namespace="/employee" method="post">
用户名:<s:textfield name="employee.username"/><br/>
密码:<s:textfield name="employee.password"/><br/>
性别:<s:radio list="#{'MAN':'男','WOMEN':'女'}" listKey="key" listValue="value" name="employee.gender"/>
<input type="submit" value="保存"/>
</s:form>
</body>
</html>
<%@ 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">
</head>
<body>
<h1><font color="red"> <s:property value="#request.message"/> </font></h1>
</body>
</html>
<%@ 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">
</head>
<body>
<h1><font color="red"> <s:property value="#request.message"/> </font></h1>
</body>
</html>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 指定spring的配置文件,默认从web根目录寻找配置文件,我们可以通过spring提供的classpath:前缀指定从类路径下寻找 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
<?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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:component-scan base-package="com.isoftstone"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="org.gjt.mm.mysql.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/isoftstone?useUnicode=true&characterEncoding=UTF-8"/>
<property name="user" value="root"/>
<property name="password" value="520123412"/>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="1"/>
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize" value="1"/>
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize" value="300"/>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="60"/>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="5"/>
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
<property name="idleConnectionTestPeriod" value="60"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>com/isoftstone/bean/Employee.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=false
</value>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--使用基于注解方式配置事务 -->
<tx:annotation-driven transaction-manager="txManager"/>
</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- 默认的视图主题 -->
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.objectFactory" value="spring" />
<package name="employee" namespace="/employee" extends="struts-default">
<action name="list" class="employeeAction">
<result name="list">/WEB-INF/page/employee.jsp</result>
</action>
<action name="manage_*" class="employeeManageAction" method="{1}">
<result name="add">/WEB-INF/page/employeeAdd.jsp</result>
<result name="message">/WEB-INF/page/message.jsp</result>
</action>
</package>
</struts>
package com.isoftstone.service;
import java.util.List;
import com.isoftstone.bean.Employee;
public interface EmployeeService {
public void save(Employee employee);
public void update(Employee employee);
public Employee find(String username);
public void delete(String... usernames);
public List<Employee> list();
}
package com.isoftstone.bean;
public class Employee {
private String username;
private String password;
private Gender gender=Gender.MAN;
public Employee() {
super();
}
public Employee(String username, String password) {
super();
this.username = username;
this.password = password;
}
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;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
}
package com.isoftstone.bean;
public enum Gender {
MAN,WOMEN;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.isoftstone.bean">
<class name="Employee">
<id name="username" length="20"/>
<property name="password" length="20" not-null="true"/>
<property name="gender" not-null="true" length="5">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">com.isoftstone.bean.Gender</param>
<!-- 12为java.sql.Types.VARCHAR常量值,即保存枚举的字面值到数据库。如果不指定type参数,保存枚举的索引值(从0开始)到数据库-->
<param name="type">12</param>
</type>
</property>
</class>
</hibernate-mapping>
package com.isoftstone.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.isoftstone.bean.Employee;
import com.isoftstone.service.EmployeeService;
@Service @Transactional
public class EmployeeServiceBean implements EmployeeService{
@Resource SessionFactory factory;
public void delete(String... usernames) {
for(String username : usernames){
factory.getCurrentSession().delete(factory.getCurrentSession().load(Employee.class, username));
}
}
@Transactional(propagation=Propagation.NOT_SUPPORTED)
public Employee find(String username) {
return (Employee)factory.getCurrentSession().get(Employee.class, username);
}
@SuppressWarnings("unchecked")
@Transactional(propagation=Propagation.NOT_SUPPORTED)
public List<Employee> list() {
return factory.getCurrentSession().createQuery("from Employee").list();
}
public void save(Employee employee) {
factory.getCurrentSession().persist(employee);
}
public void update(Employee employee) {
factory.getCurrentSession().merge(employee);
}
}
package junit.test;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.isoftstone.bean.Employee;
import com.isoftstone.bean.Gender;
import com.isoftstone.service.EmployeeService;
public class EmployeeTest {
private static EmployeeService employeeService;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
ApplicationContext act = new ClassPathXmlApplicationContext("beans.xml");
employeeService = (EmployeeService)act.getBean("employeeServiceBean");
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void save(){
employeeService.save(new Employee("liming", "123456"));
}
@Test
public void update(){
Employee employee = employeeService.find("xxxx");
employee.setGender(Gender.WOMEN);
employeeService.update(employee);
}
@Test
public void delete(){
employeeService.delete("liming");
}
@Test
public void list(){
List<Employee> ems = employeeService.list();
for(Employee em: ems)
System.out.println(em.getPassword());
}
@Test
public void find(){
Employee em = employeeService.find("liming");
System.out.println(em.getPassword());
}
}
package com.isoftstone.action;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import com.isoftstone.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
@Controller // employeeAction
public class EmployeeAction {
@Resource EmployeeService employeeService;
public String execute(){
ActionContext.getContext().put("employees", employeeService.list());
return "list";
}
}
package com.isoftstone.action;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.isoftstone.bean.Employee;
import com.isoftstone.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
@Controller @Scope("prototype")
public class EmployeeManageAction {
@Resource EmployeeService employeeService;
private Employee employee;
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public String addUI(){
return "add";
}
public String add(){
employeeService.save(employee);
ActionContext.getContext().put("message", "±£´æ³É¹¦");
return "message";
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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">
</head>
<body>
ONGL:
<br/>
<s:iterator value="#request.employees">
<s:property value="username"/> ,<s:property value="password"/>, <s:property value="gender"/><br/>
</s:iterator>
<br/>
<a href="<s:url action="manage_addUI" namespace="/employee"/>">员工添加</a>
<br/>
JSTL/EL:
<br/>
<c:forEach items="${employees}" var="employee">
${employee.username}, ${employee.password}, ${employee.gender}<br/>
</c:forEach>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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">
</head>
<body>
<s:form action="manage_add" namespace="/employee" method="post">
用户名:<s:textfield name="employee.username"/><br/>
密码:<s:textfield name="employee.password"/><br/>
性别:<s:radio list="#{'MAN':'男','WOMEN':'女'}" listKey="key" listValue="value" name="employee.gender"/>
<input type="submit" value="保存"/>
</s:form>
</body>
</html>
<%@ 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">
</head>
<body>
<h1><font color="red"> <s:property value="#request.message"/> </font></h1>
</body>
</html>
<%@ 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">
</head>
<body>
<h1><font color="red"> <s:property value="#request.message"/> </font></h1>
</body>
</html>
相关文章推荐
- Spring2.5+Struts1.3.8+JPA(Hibernate实现)整合之二
- maven+Spring+Struts2+Hibernate 整合
- 使用struts、hibernate、spring进行框架整合流程详细说明
- struts2.1.8 hibernate3.3.2 spring2.5 整合需要哪些jar包
- 传智播客--Spring中的事务管理,hibernate整合,struts整合(佟刚)
- struts-2.3+spring-4.0+hibernate-4.0整合项目
- Struts2.3+Spring2.5.6+JPA(Hibernate3)项目移植入WebLogic12容器,并整合入MyEclipse10 图文详解
- struts_spring_hibernate整合源码
- Struts 2 + Spring 2.0 + Hibernate 3.0整合笔记
- 整合Struts2.3.20 Spring4.1.3 Hibernate4.3.7 配置文件
- 轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)
- 手动配置三大框架整合,Spring+Struts2+Hibernate
- struts + spring + hibernate整合事务配置的问题(请教高手)
- struts2+hibernate+spring整合过程中遇到的问题
- Struts、Spring、Hibernate整合开发
- struts+hibernate+spring整合的文件配置详解
- Struts2.2.1 Spring3.0.4 Hibernate3.6 整合 附加springside3 [ss2h ss3 ss2hss3 ssh2 s2sh]
- Struts+Spring+Hibernate--SSH整合实例
- Struts hibernate Spring 整合
- 使用MyEclipse整合Struts+Spring+Hibernate时,在“applicationContext.xml”中提示class"org.apache.commons.dbcp.Basi