集成方式1:核心

我们没有创建applicationContext-action.xml配置文件,在该配置文件里面让Spring去管理我们的AddUserAction,但是AddUserAction的创建却是Spring产生的,但是没有对AddUserAction进行管理,
AddUserAction中使用到的依赖对象,Spring默认会根据名称自动装配

在该方式中Spring创建action对象依赖于struts2-spring-plugin.jar,该struts2-spring-plugin.jar中 在struts2-spring-plugin.jar中有一个struts-plugin.xml,里面声明了action类由spring工厂创建

上面这个属性表示的就是action由Spring来进行创建

在我们集成struts2+spring+hibernate,也就是所谓的S2SH,不可避免的要引入struts2-spring-plugin.jar插件。当引入这个插件后,原先所struts创建的action类,交给了spring创建。在struts2-spring-plugin.jar中有一个struts-plugin.xml,里面声明了action类由spring工厂创建

我们来看下具体的操作步骤:

集成Struts2+Spring+Hibernate

第一种方案:让Spring创建Struts2的Action,不让Spring完全管理Struts2的Action
Struts2 Action中的依赖对象,默认会根据名称自动装配

1、创建web项目

2、引入Struts2的依赖包,将依赖包拷贝到WEB-INF/lib下
* commons-logging-1.0.4.jar
* freemarker-2.3.15.jar
* ognl-2.7.3.jar
* struts2-core-2.1.8.1.jar
* xwork-core-2.1.6.jar
* commons-fileupload-1.2.1.jar

3、引入Spring的依赖包,将依赖包拷贝到WEB-INF/lib下
* spring.jar
* lib/aspectj/*.jar

4、引入hibernate相关依赖包,将依赖包拷贝到WEB-INF/lib下
* hibernate3.jar
* lib/*.jar

5、数据库驱动
* MySQl JDBC Driver

6、将Struts2和Spring集成的依赖包拷贝到WEB-INF/lib下
* struts2-spring-plugin-2.1.8.1.jar

7、在web.xml文件中配置StrutsPrepareAndExecuteFilter
<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>

8、提供struts.xml配置文件,提供必要属性的配置
* struts.i18n.encoding=GB18030
* struts.configuration.xml.reload=true
* struts.devMode=true

9、提供Spring的配置文件
* applicationContext-service.xml
* applicationContext-dao.xml
* applicationContext-common.xml

10、提供hibernate.cfg.xml配置文件,提供log4j

11、在web.xml文件中配置Spring的ContextLoaderListener,创建BeanFactory
<context-param>
<param-name>contextConfigLocation</param-name>
<!--
<param-value>classpath:applicationContext-*.xml</param-value>
-->
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>、

11、在web.xml文件中配置OpenSessionInViewFilter(需要放到Struts2的Filter前面)
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

12、提供用户添加表单和add_success.jsp

13、建立User实体类,编写hibernate映射文件,将映射文件加入到hibernate.cfg.xml中

14、建立UserDao和UserService,并进行实现

15、建立Struts2的Action,并配置到Struts2的配置文件中

16、在jsp中调用Action

17、我们没有创建applicationContext-action.xml配置文件,在该配置文件里面去管理我们的AddUserAction,但是AddUserAction的创建却是Spring产生的,但是没有对AddUserAction进行管理,
AddUserAction中使用到的依赖对象,Spring默认会根据名称自动装配

我们来看下整个项目的视图

首先来看配置文件

注意点:

第一hibernate的配置文件:

hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="/com/weiyuan/test/domain/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>

表示要连接的数据库是test,用户名是root,密码是123456
如果使用的mysql必须配置 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.show_sql">true</property>表示在打印台输出创建的sql语言

Hibernate配置文件的hbm2ddl.auto属性

问题就出在我把hbm2ddl.auto的值设为create了,根据Hibernate的文档,hbm2ddl.auto有四个可选值:

值 定义
update 最常用的值,第一次加载hibernate时根据model类会自动建立起表的结构(前提是先建立好数据库),以后加载hibernate时根据 model类自动更新表结构,即使表结构改变了但表中的行仍然存在不会删除以前的行。要注意的是当部署到服务器后,表结构是不会被马上建立起来的,是要等 应用第一次运行起来后才会
validate 每次加载hibernate时,验证创建数据库表结构,只会和数据库中的表进行比较,不会创建新表,但是会插入新值
create 每次加载hibernate时都会删除上一次的生成的表,然后根据你的model类再重新来生成新表,哪怕两次没有任何改变也要这样执行
create-drop 每次加载hibernate时根据model类生成表,但是sessionFactory一关闭,表就自动删除

<mapping resource="/com/weiyuan/test/domain/User.hbm.xml"/> 表示通过实体类和数据库映射的配置文件,表示把/com/weiyuan/test/domain/User映射到数据库中的字段

当程序运行的时候,会自动运行加载hibernate.cfg.xml,和数据库进行连接,然后通过mapping 对于的配置文件,在数据库中创建对应的数据库表

2、配置Spring的配置文件

先在web.xml中进行配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SSH_01</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- 需要配置在struct2的OpenSessionInView要放在struts2的过滤器的前面 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter> <filter-mapping>
<filter-name>OpenSessionInViewFilter</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> <!-- 配置spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!--
<param-value>classpath:applicationContext-*.xml</param-value>
-->
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

web.xml配置了三种:

1、配置了struct2

<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>

2、配置了spring

<!-- 配置spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!--
<param-value>classpath:applicationContext-*.xml</param-value>
-->
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

3、配置了OpenSessionInViewFilter

该类主要实现Hibernate延迟加载,但是必须注意的是在web.xml中该类配置的顺序必须在配置struct2之前才有效果

不能写成

<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>

<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

4、我们来分析下web.xml中对spring配置文件的理解

<!-- 配置spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!--
<param-value>classpath:applicationContext-*.xml</param-value>
-->
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

这里<param-value>classpath:applicationContext.xml</param-value>  表示要加载的配置文件的路径在当前classpath目录下,就是src目录下

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: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/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">
<import resource="applicationContext-service.xml"/>
<import resource="applicationContext-dao.xml"/>
<import resource="applicationContext-common.xml"/>
</beans>

在该文件夹中加载applicationContext-service.xml,applicationContext-dao.xml,applicationContext-common.xml配置文件,就是在程序运行的时候就去加载这三个配置文件
applicationContext-service.xml该配置文件主要用于spring对mvc中的业务层serivice对象进行管理,所有的Service层都需要在该配置文件中配置
applicationContext-dao.xml该配置文件主要对mvc层中的数据库dao层进行配置管理
applicationContext-common.xml主要对一些常用的公共类进行配置和管理,一些常用的Utils工具类就在该文件中进行配置

3、现在我们来看看具体的实体类,先创建实体类,对应

package com.weiyuan.test.domain;

public class User {
private String userCode; private String userName; private String age; public String getUserCode() {
return userCode;
} public void setUserCode(String userCode) {
this.userCode = userCode;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getAge() {
return age;
} public void setAge(String age) {
this.age = age;
} @Override
public String toString() {
return "User [userCode=" + userCode + ", userName=" + userName
+ ", age=" + age + "]";
} }

然后在该名下com.weiyuan.test.domain下创建对应的hibernate的配置文件,该配置文件为

配置文件必须和实体类在同一个包名下User.hbm.xml,中User必须和实体类的名字一样,hbm.xml后面是默认的

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.weiyuan.test.domain.User" table="t_user">
<id name="userCode">
<generator class="assigned"/>
</id>
<property name="userName"/>
<property name="age"/>
</class>
</hibernate-mapping>

该文件的内容

property 属性的值必须和实体类的属性的名称一一对应

在hibernate中一个数据模型的主键常用有三种形式:uuid、native、assigned,分别是通用唯一标识、自增、自定义。
1、uuid是系统产生的,insert数据库时相比native要快很多,但是uuid是一长串无序字符串,理论上讲查找起来会慢一点,但是不太会影响开发的。而native是数据库生成,在insert时会先计算所以会比uuid慢一点,但是在查找和删除数据时,会比较方便。
2、uuid和assigned的生成是在程序中完成的,一个是自动,一个是手动。所以在进行session.save()时,不会产生sql语句,数据库中也不会有数据。而native需要读取数据库数据才能完成自动递增,所以在执行session.save()时,就会产生相应的sql语句,数据库中就会有数据(缓存中id是有值的)。

这样当程序运行的就会在数据库中创建t_user这张表

CREATE TABLE `t_user` (
`userCode` varchar(255) NOT NULL,
`userName` varchar(255) default NULL,
`age` varchar(255) default NULL,
PRIMARY KEY (`userCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

4、创建dao类

package com.weiyuan.test.dao;

import com.weiyuan.test.domain.User;

public interface UserDao {

    public void add(User user) ;
}

对应的实现类为:

package com.weiyuan.test.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.weiyuan.test.domain.User;

/**
*
* 继承:HibernateDaoSupport中使用到了sessionFactroy
* 我们需要在配置文件中使用spring自动产生sessionFactroy
* 我们需要在配置文件中使用spring自动产生UserDaoImpl
* */ public class UserDaoImpl extends HibernateDaoSupport implements UserDao { /**
* 需要hibernate的sessionFactory将用户添加到数据库中
* */
@Override
public void add(User user) {
// TODO Auto-generated method stub
getHibernateTemplate().save(user);
} }

该实现类继承了HibernateDaoSupport ,然后将对象插入到数据库表t_user中

  由于Hibernate集成了JDBC,所以在访问数据库时,与直接使用JDBC访问数据库相比,Hibernate在连接、访问数据库时的代码减少了很大一大半。但由此而来也相应必须增加访问Hibernate配置文件和SessionFactory、Session的打开、关闭的代码。为了解决以上相同代码出现的复用问题,Hibernate对此又进行了再一次封装,于是,幸运地出现了HibernateDaoSupport。因此,在使用HibernateDaoSupport模板对数据库访问时,更加方便、简单,特别是进行简单的增删改查。

    下面是我自己写的一点代码参考:
/**
* @author wifygoo
* 对企业信息的简单增删改查。
*/
public class EnterpriseDaoImpl extends HibernateDaoSupport implements
EnterpriseDao {
/**
* @param Enterprise
* 删除某条企业信息。
*/
public void del(Enterprise enterprise) {
this.getHibernateTemplate().delete(enterprise);
}
/**
* @return 所有的企业信息。
* 查询所有的企业信息。
*/
@SuppressWarnings("unchecked")
public List<Enterprise> findAllEnterprises() {
String hql = "from Enterprise enterprise";
return this.getHibernateTemplate().find(hql);
}
/**
* @param Integer,企业编号。
* @return 某个企业信息。
* 通过企业编号查询企业信息。
*/
public Enterprise findEnterpriseById(Integer id) {
return (Enterprise) this.getHibernateTemplate().load(Enterprise.class, id);
}
/**
* @param Enterprise
* 添加企业信息。
*/
public void save(Enterprise enterprise) {
this.getHibernateTemplate().save(enterprise);
}
/**
* @param Enterprise
* 修改企业信息。
*/
public void update(Enterprise enterprise) {
this.getHibernateTemplate().update(enterprise);
}
}

使用借助于HibernateTemplate的模板访问方式访问数据库,大大减少了代码,但是必须依赖于SessionFactory这个对象,这个SessionFactory对象的产生我们可以让Spring来给我们产生,并对该对象进行管理,我们可以在上面创建的applicationContext-common.xml来产生了管理SessionFactory这个对象

applicationContext-common.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: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/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">
<!-- 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean> <!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!-- 配置事务的传播特性(配置Advice) -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
<tx:method name="del*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice> <!-- 配置哪些类的哪些方法使用事务(配置事务边界,配置Pointcut) -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.weiyuan.test.service.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
</beans>

上面这个配置文件有两个地方需要注意的:

<property name="configLocation" value="classpath:hibernate.cfg.xml"/> 加载hibernate配置文件的路径和名称是当前的src目录下

<aop:pointcut id="allManagerMethod" expression="execution(* com.weiyuan.test.service.*.*(..))"/>事务有效的函数的名称是在所有的包名下com.weiyuan.test.service的函数调用dao层访问数据库事务都有效

然后在applicationContext-dao.xml对dao进行配置,让Spring进行管理和配置

<?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: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/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">
<bean id="userDao" class="com.weiyuan.test.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>

上面就是创建userDao对象的时候,因为该对象继承了HibernateDaoSupport ,创建HibernateDaoSupport 对象的时候需要使用到sessionFactory对象,所以上面ref了applicationContext-common.xml中配置的sessionFactory对象

5、编写Service业务操作类

package com.weiyuan.test.service;

import com.weiyuan.test.domain.User;

public interface UserService {

    public void add(User user);
}

实现类:

package com.weiyuan.test.service;

import com.weiyuan.test.dao.UserDao;
import com.weiyuan.test.domain.User; public class UserServiceImpl implements UserService { /**
* 记得在applicationContext-service.xml配置使用Spring自动产生UserDao类
* */
private UserDao userDao;
@Override
public void add(User user) {
// TODO Auto-generated method stub
userDao.add(user);
}
public UserDao getUserDao() {
return userDao;
}
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} }

现在我们要在applicationContext-service.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: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/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">
<bean id="userService" class="com.weiyuan.test.service.UserServiceImpl">
<property name="userDao" ref="userDao"/>
</bean>
</beans>

5、接下来创建文明的action

package com.weiyuan.test.web.action;

import com.weiyuan.test.domain.User;
import com.weiyuan.test.service.UserService; public class AddUserAction { private User user; /**
* 这里的名字必须和applicationContext-service.xml中配置的名字一一对应起来
* <bean id="userService" class="com.weiyuan.test.service.UserServiceImpl">
* */
private UserService userService; public User getUser() {
return user;
} public void setUser(User user) {
this.user = user;
} public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
} public String execute() throws Exception{
System.out.println(""+user.toString());
userService.add(user);
return "sucess";
} }

这里action的创建和管理就没有单独的applicationContext-action.xml对其进行配置,因为引入了

它会由spring自动创建action对象,但是不会对action对象进行管理,

我们没有创建applicationContext-action.xml配置文件,在该配置文件里面让Spring去管理我们的AddUserAction,但是AddUserAction的创建却是Spring产生的,但是没有对AddUserAction进行管理,
AddUserAction中使用到的依赖对象private UserService userService;,Spring默认会根据名称自动装配,名称必须和

这里的名字必须和applicationContext-service.xml中配置的名字一一对应起来
* <bean id="userService" class="com.weiyuan.test.service.UserServiceImpl">

文明来看看struct.xml对action的配置

<?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.i18n.encoding" value="GB18030"/>
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="struts.devMode" value="true"/>
<package name="user" extends="struts-default" >
<action name="add" class="com.weiyuan.test.web.action.AddUserAction">
<result name="sucess">/add_success.jsp</result>
</action>
</package>
</struts>

文明来看看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> </head> <body>
<form action="add.action" method="post">
用户代码:<input type="text" name="user.userCode"><br>
用户姓名:<input type="text" name="user.userName"><br>
年龄:<input type="text" name="user.age"><br>
<input type="submit" value="添加">
</form>
</body>
</html>

添加用户成功的页面:

add_success.jsp

代码下载地址为:

https://pan.baidu.com/s/1bVF9pG

9、ssh的集成方式1的更多相关文章

  1. 9、ssh的集成方式2

    1.在第一种的集成方式中,通过struts2-spring-plugin-2.1.8.1.jar这个插件让spring自动产生对应需要的action类,不需要在对应的spring.xml文件中进行配置 ...

  2. 使用ssh key的方式建立和git服务器的通信

    1.以前大家好像都在用https的方式同git来同步代码,但是到了新公司后,主管说要配ssh key,所以大概了解一下 An SSH key allows you to establish a sec ...

  3. intellij idea 高级用法之:集成JIRA、UML类图插件、集成SSH、集成FTP、Database管理

    之前写过一篇IntelliJ IDEA 13试用手记,idea还有很多高大上的功能,易用性几乎能与vs.net媲美,反正我自从改用idea后,再也没开过eclipse,今天来看几个高级功能: 一.与J ...

  4. Linux使用SSH远程连接方式和更改密码 ,自己空间转移过来的。

    一. 远程连接Linux系统需要一个方便的SSH连接工具putty就不错!工具在本日志的附件下载,解压密码是QQ号,云盘访问密码 90891.把远程主机ip和端口号填写上然后选择连接方式为“SSH”. ...

  5. SSH证书登录方式(无password验证登录)

    经常在工作中须要在各个Linux机间进行跳转,每次password的输入成了麻烦,并且也不安全.在实际使用中,在windows下常使用secureCRT工具或teraterm工具进行SSH登录.以及实 ...

  6. git中的ssh和https方式的使用(gitee为例)

    在使用git管理代码,或者使用github,国内的码云(gitee)的时候,有两种方式可以使用,分别是https和ssh,以下均使用gitee为例. ssh方式 配置ssh,如果不配置ssh的话,cl ...

  7. Putty远程SSH免密码方式链接Linxu

    1.首先确保Linxu服务器安装了ssh服务,可以输入ssh命令测试. ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spe ...

  8. Others-接口集成方式

    1. 异步通信方式可分为不互锁.半互锁和全互锁三种类型: a.不互锁方式 主模块发出请求信号后,不等待接到从模块的回答信号,而是经过一段时间.确认从模块已收到请求信号后,便撤消其请求信号:从设备接到请 ...

  9. spring和resteasy 的集成方式

    spring和resteasy集成,三种主要的方式, 对于和jboss as7的集成不需要做任何工作,jboss默认集成了resteasy,只需要对业务pojo做一些jax-rs的注解标注即可.这里讲 ...

随机推荐

  1. TCP / IP 精彩回顾-必看

    TCP/IP 协议出现的原因是互联网世界各个主机作为一个个独立的个体,如何制定统一的规则让他们互相通信是达成万物互联的纽带.基于此,设定了 TCP/IP 协议来规范网络访问行为.TCP/IP 并不是一 ...

  2. 关于vue 中elementui 的表格边框隐藏

    最近写到一个项目需要实现边框隐藏,网上查找了好多笔记,回答都好含糊不清.为此,记录一下自己的实现方法: 需求: 要将如下表格边框去除                   效果图:           ...

  3. (Java实现) 蓝桥杯 国赛 重复模式

    标题:重复模式 作为 drd 的好朋友,技术男 atm 在 drd 生日时送给他一个超长字符串 S .atm 要 drd 在其中找出一个最长的字符串 T ,使得 T 在 S 中至少出现了两次,而他想说 ...

  4. (Java实现) N皇后问题

    n皇后问题是一个以国际象棋为背景的问题:在n×n的国际象棋棋盘上放置n个皇后,使得任何一个皇后都无法直接吃掉其他的皇后,即任意两个皇后都不能处于同一条横行.纵行或斜线上. 蛮力法思想: 解决n皇后问题 ...

  5. Java实现 蓝桥杯 算法训练 递归求二项式系数

    算法训练 6-1 递归求二项式系数值 时间限制:10.0s 内存限制:256.0MB 问题描述 样例输入 一个满足题目要求的输入范例. 3 10 样例输出 与上面的样例输入对应的输出. 数据规模和约定 ...

  6. Java实现蓝桥杯模拟元音单词的验证

    问题描述 小明对类似于 hello 这种单词非常感兴趣,这种单词可以正好分为四段,第一段由一个或多个辅音字母组成,第二段由一个或多个元音字母组成,第三段由一个或多个辅音字母组成,第四段由一个或多个元音 ...

  7. Javascript实现万年历(日历表)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Java实现 蓝桥杯 历届试题 城市建设

    问题描述 栋栋居住在一个繁华的C市中,然而,这个城市的道路大都年久失修.市长准备重新修一些路以方便市民,于是找到了栋栋,希望栋栋能帮助他. C市中有n个比较重要的地点,市长希望这些地点重点被考虑.现在 ...

  9. Java实现微生物增殖

    微生物增殖 假设有两种微生物 X 和 Y X出生后每隔3分钟分裂一次(数目加倍),Y出生后每隔2分钟分裂一次(数目加倍). 一个新出生的X,半分钟之后吃掉1个Y,并且,从此开始,每隔1分钟吃1个Y. ...

  10. Java实现第八届蓝桥杯青蛙跳杯子

    青蛙跳杯子 题目描述 X星球的流行宠物是青蛙,一般有两种颜色:白色和黑色. X星球的居民喜欢把它们放在一排茶杯里,这样可以观察它们跳来跳去. 如下图,有一排杯子,左边的一个是空着的,右边的杯子,每个里 ...