struts2+spring3+hibernate4整合

  1. 准备工作

 

struts2
spring3.1
hibernate4
数据库,连接池

 

2.配置文件

 

web.xml

 

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!--  
  3.      Licensed to the Apache Software Foundation (ASF) under one or more  
  4.       contributor license agreements.  See the NOTICE file distributed with  
  5.       this work for additional information regarding copyright ownership.  
  6.       The ASF licenses this file to You under the Apache License, Version 2.0  
  7.       (the "License"); you may not use this file except in compliance with  
  8.       the License.  You may obtain a copy of the License at  
  9.   
  10.           http://www.apache.org/licenses/LICENSE-2.0  
  11.   
  12.       Unless required by applicable law or agreed to in writing, software  
  13.       distributed under the License is distributed on an "AS IS" BASIS,  
  14.       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  15.       See the License for the specific language governing permissions and  
  16.       limitations under the License.  
  17. -->  
  18. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  19.     xmlns="http://java.sun.com/xml/ns/javaee"   
  20.     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"   
  21.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"   
  22.     metadata-complete="true" version="3.0">  
  23.     <!--Spring-->  
  24.     <context-param>  
  25.         <param-name>contextConfigLocation</param-name>  
  26.         <param-value>   
  27.             classpath*:applicationContext*.xml  
  28.             classpath*:*Context.xml  
  29.         </param-value>  
  30.     </context-param>  
  31.     <listener>  
  32.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  33.     </listener>  
  34.   
  35.     <!-- 配置spiring security --><!--  
  36.     <filter>  
  37.         <filter-name>springSecurityFilterChain</filter-name>  
  38.         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
  39.     </filter>  
  40.     <filter-mapping>  
  41.         <filter-name>springSecurityFilterChain</filter-name>  
  42.         <url-pattern>/*</url-pattern>  
  43.     </filter-mapping>-->  
  44.     <!-- 配置spiring security结束 -->  
  45.   
  46.     <filter>  
  47.         <filter-name>struts2</filter-name>  
  48.         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  49.     </filter>  
  50.     <filter-mapping>  
  51.         <filter-name>struts2</filter-name>  
  52.         <url-pattern>*.action</url-pattern>  
  53.     </filter-mapping>  
  54.     <!--OpenSessionInViewFilter-->  
  55.     <filter>  
  56.          <filter-name>openSessionInViewFilter</filter-name>  
  57.          <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>  
  58.          <init-param>  
  59.              <param-name>sessionFactoryBeanName</param-name>  
  60.              <param-value>sessionFactory</param-value>  
  61.          </init-param>  
  62.      </filter>  
  63.      <filter-mapping>  
  64.          <filter-name>openSessionInViewFilter</filter-name>  
  65.          <url-pattern>/*</url-pattern>  
  66.      </filter-mapping>      
  67.   
  68.     <welcome-file-list>  
  69.         <welcome-file>index.jsp</welcome-file>  
  70.     </welcome-file-list>  
  71. </web-app>  

 

 Struts.xml

 

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE struts PUBLIC  
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd">  
  5. <struts>  
  6.     <constant name="struts.enable.DynamicMethodInvocation" value="false" />  
  7.     <constant name="struts.devMode" value="false" />  
  8.   
  9.       
  10.     <!-- 交给spring管理 -->  
  11.     <constant name="struts.objectFactory" value="spring" />  
  12.     <!--国际化语言文件编码-->  
  13.     <constant name="struts.i18n.encoding" value="UTF-8" />  
  14.     <!--国际化-->  
  15.     <constant name="struts.custom.i18n.resources" value="i18n.message" />  
  16.       
  17.     <!--加载所有Struts2配置文件-->  
  18.     <include file="*/struts.xml"/>  
  19.   
  20.     <package name="default" namespace="/" extends="struts-default">  
  21.         <action name="userAction" class="userAction" method="doUser">  
  22.             <result>/user.jsp</result>  
  23.         </action>  
  24.     </package>  
  25.           
  26. </struts>  

 

 Spring 配置文件

 

  • applicationContext.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.      xmlns:context="http://www.springframework.org/schema/context"  
  5.      xmlns:tx="http://www.springframework.org/schema/tx"  
  6.      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8.          http://www.springframework.org/schema/context  
  9.          http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
  10.     <!-- UT框架Spring Configer -->  
  11.       
  12.     <!-- 配置使用注解 -->  
  13.     <context:annotation-config />  
  14.       
  15.         <!-- 自动装在   
  16.     <context:component-scan base-package="cn.net.comsys.ut"/>  
  17.     -->  
  18.           
  19.   
  20. </beans>  

 

  • databaseContext.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:aop="http://www.springframework.org/schema/aop"   
  6.     xmlns:tx="http://www.springframework.org/schema/tx"   
  7.     xsi:schemaLocation="  
  8.         http://www.springframework.org/schema/beans  
  9.         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  10.         http://www.springframework.org/schema/context  
  11.         http://www.springframework.org/schema/context/spring-context-3.0.xsd  
  12.         http://www.springframework.org/schema/tx   
  13.         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd  
  14.         http://www.springframework.org/schema/aop   
  15.         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">  
  16.         <!--加载数据库信息-->  
  17.     <bean   
  18.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  19.         <property name="locations" value="classpath:jdbc.properties"/>  
  20.     </bean>     
  21.     <!--数据源-->  
  22.     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  
  23.         <property name="driverClassName" value="${jdbc.driverClassName}"/>  
  24.         <property name="url" value="${jdbc.url}"/>  
  25.         <property name="username" value="${jdbc.username}"/>  
  26.         <property name="password" value="${jdbc.password}"/>  
  27.         <property name="maxActive" value="${dbcp.maxActive}"/>  
  28.         <property name="maxIdle" value="${dbcp.maxIdle}"/>  
  29.         <property name="maxWait" value="${dbcp.maxWait}"/>  
  30.     </bean>  
  31.   
  32.     <!-- SessionFactory-->  
  33.     <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">  
  34.         <property name="dataSource" ref="dataSource"/>  
  35.         <!--hibernate config-->  
  36.         <property name="hibernateProperties">  
  37.             <props>  
  38.                 <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
  39.                 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
  40.                 <prop key="connection.characterEncoding">${connection.characterEncoding}</prop>  
  41.                 <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>  
  42.             </props>  
  43.         </property>  
  44.         <!--映射-->  
  45.         <property name="annotatedClasses">  
  46.             <list>  
  47.                 <value>cn.net.comsys.ut.model.Users</value>  
  48.                 <value>cn.net.comsys.ut.model.Roles</value>  
  49.             </list>  
  50.         </property>         
  51.     </bean>  
  52.     <!-- 事务管理器 -->    
  53.     <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">    
  54.         <property name="sessionFactory" ref="sessionFactory"/>    
  55.     </bean>   
  56.   
  57.     <tx:advice id="txAdvice" transaction-manager="transactionManager">    
  58.         <tx:attributes>    
  59.             <tx:method name="save*" propagation="REQUIRED" />    
  60.             <tx:method name="add*" propagation="REQUIRED" />    
  61.             <tx:method name="update*" propagation="REQUIRED" />    
  62.             <tx:method name="del*" propagation="REQUIRED" />    
  63.             <!--hibernate4必须配置为开启事务 否则 getCurrentSession()获取不到-->    
  64.             <tx:method name="find*" propagation="REQUIRED" read-only="true" />  
  65.         </tx:attributes>    
  66.     </tx:advice>    
  67.     <aop:config expose-proxy="true">    
  68.         <!-- 只对业务逻辑层实施事务 -->    
  69.         <aop:pointcut id="txPointcut" expression="execution(* cn.net.comsys.ut.service.impl.*.*(..))" />    
  70.         <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>    
  71.     </aop:config>    
  72.       
  73. </beans>  
  •  jdbc.properties
Properties代码   收藏代码
  1. ######################### Mysql Config ##################################  
  2. jdbc.driverClassName=org.gjt.mm.mysql.Driver  
  3. jdbc.url=jdbc:mysql://localhost:3306/test?characterEncoding=utf-8  
  4. jdbc.username=ut  
  5. jdbc.password=ut  
  6. ######################### Hibernate Config ##################################  
  7. #hibernate信息  
  8. hibernate.dialect=org.hibernate.dialect.MySQLDialect  
  9. hibernate.show_sql=true  
  10. connection.characterEncoding=utf-8  
  11. hibernate.current_session_context_class = org.springframework.orm.hibernate4.SpringSessionContext  
  12. #hibernate.current_session_context_class = thread  
  13. ######################### DBCP Config ##################################  
  14. #配置连接池信息  
  15. dbcp.maxActive=10  
  16. dbcp.maxIdle=3  
  17. dbcp.maxWait=10  
  18. dbcp.whenExhaustedAction=1  
  19. dbcp.validationQuery=select 1 from dual  
  20. dbcp.testOnBorrow=true  
  21. dbcp.testOnReturn=false  
  •  daoContext.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xsi:schemaLocation="  
  6.         http://www.springframework.org/schema/beans  
  7.         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8.         http://www.springframework.org/schema/context  
  9.         http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
  10.     <bean id="userDao" class="cn.net.comsys.ut.dao.impl.UserDaoImpl"/>  
  11.   
  12. </beans>  
  •  serviceContext.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xsi:schemaLocation="  
  6.         http://www.springframework.org/schema/beans  
  7.         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8.         http://www.springframework.org/schema/context  
  9.         http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
  10.     <bean id="userService" class="cn.net.comsys.ut.service.impl.UserServiceImpl"/>  
  11.   
  12. </beans>  
  •  actionContext.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xsi:schemaLocation="  
  6.         http://www.springframework.org/schema/beans  
  7.         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8.         http://www.springframework.org/schema/context  
  9.         http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
  10.     <bean id="userAction" class="cn.net.comsys.ut.action.UserAction" scope="prototype"/>  
  11.   
  12. </beans>  
  3.编码
  • Users.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.model;  
  2.   
  3. import java.io.Serializable;  
  4. import java.util.Set;  
  5.   
  6. import javax.persistence.Basic;  
  7. import javax.persistence.CascadeType;  
  8. import javax.persistence.Entity;  
  9. import javax.persistence.FetchType;  
  10. import javax.persistence.GeneratedValue;  
  11. import javax.persistence.GenerationType;  
  12. import javax.persistence.Id;  
  13. import javax.persistence.JoinColumn;  
  14. import javax.persistence.JoinTable;  
  15. import javax.persistence.ManyToMany;  
  16. import javax.persistence.Table;  
  17. import javax.persistence.Transient;  
  18.   
  19. @Entity  
  20. @Table(name="ut_users")  
  21. public class Users implements Serializable{  
  22.     /** 
  23.      * serialVersionUID 
  24.      */  
  25.     private static final long serialVersionUID = 1L;  
  26.     /** 
  27.      * 用户编号  
  28.      */  
  29.     @Id  
  30.     @GeneratedValue(strategy=GenerationType.AUTO)  
  31.     private int userId;  
  32.     /** 
  33.      * 账号  
  34.      */  
  35.     private String loginId;  
  36.     /** 
  37.      * 密码  
  38.      */  
  39.     private String password;  
  40.     /** 
  41.      * 姓名  
  42.      */  
  43.     private String name;  
  44.     /** 
  45.      * 手机  
  46.      */  
  47.     private String phone;  
  48.     /** 
  49.      * 邮箱  
  50.      */  
  51.     private String email;  
  52.     /** 
  53.      * 身份证  
  54.      */  
  55.     private String cardId;  
  56.     /** 
  57.      * 管理员标识  
  58.      */  
  59.     private int isDepartAdmin;  
  60.     /** 
  61.      * @aggregation 
  62.      * @clientCardinality 1 
  63.      * @supplierCardinality 0..*  
  64.      */  
  65.     @ManyToMany(targetEntity=cn.net.comsys.ut.model.Roles.class,  
  66.             cascade={CascadeType.PERSIST, CascadeType.MERGE},  
  67.             fetch=FetchType.EAGER)  
  68.     @JoinTable(name="ut_user_role",  
  69.             joinColumns={@JoinColumn(name="userId")},  
  70.             inverseJoinColumns={@JoinColumn(name="roleId")})  
  71.     private Set<Roles> role;  
  72.       
  73.     public int getUserId() {  
  74.         return userId;  
  75.     }  
  76.     public void setUserId(int userId) {  
  77.         this.userId = userId;  
  78.     }  
  79.   
  80.     public String getLoginId() {  
  81.         return loginId;  
  82.     }  
  83.     public void setLoginId(String loginId) {  
  84.         this.loginId = loginId;  
  85.     }  
  86.     public String getPassword() {  
  87.         return password;  
  88.     }  
  89.     public void setPassword(String password) {  
  90.         this.password = password;  
  91.     }  
  92.     public String getName() {  
  93.         return name;  
  94.     }  
  95.     public void setName(String name) {  
  96.         this.name = name;  
  97.     }  
  98.     public String getPhone() {  
  99.         return phone;  
  100.     }  
  101.     public void setPhone(String phone) {  
  102.         this.phone = phone;  
  103.     }  
  104.     public String getEmail() {  
  105.         return email;  
  106.     }  
  107.     public void setEmail(String email) {  
  108.         this.email = email;  
  109.     }  
  110.     public String getCardId() {  
  111.         return cardId;  
  112.     }  
  113.     public void setCardId(String cardId) {  
  114.         this.cardId = cardId;  
  115.     }  
  116.     public int getIsDepartAdmin() {  
  117.         return isDepartAdmin;  
  118.     }  
  119.     public void setIsDepartAdmin(int isDepartAdmin) {  
  120.         this.isDepartAdmin = isDepartAdmin;  
  121.     }  
  122.     public Set<Roles> getRole() {  
  123.         return role;  
  124.     }  
  125.     public void setRole(Set<Roles> role) {  
  126.         this.role = role;  
  127.     }  
  128.       
  129. }  
  •  Roles.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.model;  
  2.   
  3. import java.io.Serializable;  
  4. import java.util.Set;  
  5.   
  6. import javax.persistence.Basic;  
  7. import javax.persistence.CascadeType;  
  8. import javax.persistence.Entity;  
  9. import javax.persistence.FetchType;  
  10. import javax.persistence.GeneratedValue;  
  11. import javax.persistence.GenerationType;  
  12. import javax.persistence.Id;  
  13. import javax.persistence.ManyToMany;  
  14. import javax.persistence.Table;  
  15. import javax.persistence.Transient;  
  16. @Entity  
  17. @Table(name="ut_roles")  
  18. public class Roles implements Serializable{  
  19.     /** 
  20.      * serialVersionUID 
  21.      */  
  22.     private static final long serialVersionUID = 1L;  
  23.     /** 
  24.      * 角色编号  
  25.      */  
  26.     @Id  
  27.     @GeneratedValue(strategy=GenerationType.AUTO)  
  28.     private int roleId;  
  29.     /** 
  30.      * 角色名称  
  31.      */  
  32.     private String roleName;  
  33.     /** 
  34.      * 状态:禁用(0),激活(1)  
  35.      */  
  36.     private int status;  
  37.     /** 
  38.      * 描述  
  39.      */  
  40.     private String description;  
  41.       
  42.     private int parentId;  
  43.       
  44.     @ManyToMany(  
  45.             cascade={CascadeType.PERSIST,CascadeType.MERGE},  
  46.             mappedBy="role",  
  47.             targetEntity=cn.net.comsys.ut.model.Users.class  
  48.         )  
  49.   
  50.     private Set<Users> user;  
  51.   
  52.     public int getRoleId() {  
  53.         return roleId;  
  54.     }  
  55.   
  56.     public void setRoleId(int roleId) {  
  57.         this.roleId = roleId;  
  58.     }  
  59.   
  60.     public String getRoleName() {  
  61.         return roleName;  
  62.     }  
  63.   
  64.     public void setRoleName(String roleName) {  
  65.         this.roleName = roleName;  
  66.     }  
  67.   
  68.     public int getStatus() {  
  69.         return status;  
  70.     }  
  71.   
  72.     public void setStatus(int status) {  
  73.         this.status = status;  
  74.     }  
  75.   
  76.     public String getDescription() {  
  77.         return description;  
  78.     }  
  79.   
  80.     public void setDescription(String description) {  
  81.         this.description = description;  
  82.     }  
  83.   
  84.     public int getParentId() {  
  85.         return parentId;  
  86.     }  
  87.   
  88.     public void setParentId(int parentId) {  
  89.         this.parentId = parentId;  
  90.     }  
  91.   
  92.     public Set<Users> getUser() {  
  93.         return user;  
  94.     }  
  95.   
  96.     public void setUser(Set<Users> user) {  
  97.         this.user = user;  
  98.     }  
  99.       
  100. }  
Java代码   收藏代码
  1. DAO层  
  •  IUserDao.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.dao.interfaces;  
  2.   
  3. import java.util.List;  
  4.   
  5. import cn.net.comsys.ut.model.Users;  
  6.   
  7. public interface IUserDao{  
  8.   
  9.     public List<Users> findUser();  
  10.       
  11.     public List<Users> findUser(String loginId);  
  12. }  
  13.                                                                                                                                           
  •  UserDaoImpl.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.dao.impl;  
  2.   
  3. import java.util.List;  
  4.   
  5. import javax.annotation.Resource;  
  6.   
  7. import org.hibernate.Session;  
  8. import org.hibernate.SessionFactory;  
  9.   
  10. import cn.net.comsys.ut.dao.interfaces.IUserDao;  
  11. import cn.net.comsys.ut.model.Users;  
  12.   
  13. public class UserDaoImpl implements IUserDao {  
  14.   
  15.     @Resource  
  16.     private SessionFactory sessionFactory;  
  17.   
  18.     @Override  
  19.     public List<Users> findUser() {  
  20.         Session session = sessionFactory.getCurrentSession();  
  21.         List<Users> userList = session.createQuery("from Users").list();  
  22.         return userList;  
  23.     }  
  24.   
  25.     @Override  
  26.     public List<Users> findUser(String loginId) {  
  27.           
  28.         Session session = sessionFactory.getCurrentSession();  
  29.         List<Users> userList = session.createQuery("from Users user where user.loginId= :loginId").setString("loginId", loginId).list();  
  30.           
  31.         return userList;  
  32.     }  
  33.       
  34. }  
Java代码   收藏代码
  1. 业务层  
  •  IUserService.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.service.interfaces;  
  2.   
  3. import java.util.List;  
  4.   
  5. import cn.net.comsys.ut.model.Users;  
  6.   
  7. public interface IUserService {  
  8.   
  9.     public List<Users> findUser();  
  10.       
  11.     public List<Users> findUser(String loginId);  
  12. }  
  •  UserServiceImpl.java
Java代码   收藏代码
  1. package cn.net.comsys.ut.service.impl;  
  2.   
  3. import java.util.List;  
  4.   
  5. import javax.annotation.Resource;  
  6.   
  7. import cn.net.comsys.ut.dao.interfaces.IUserDao;  
  8. import cn.net.comsys.ut.model.Users;  
  9. import cn.net.comsys.ut.service.interfaces.IUserService;  
  10.   
  11. public class UserServiceImpl implements IUserService{  
  12.       
  13.     @Resource  
  14.     private IUserDao userDao;  
  15.   
  16.     public List<Users> findUser() {  
  17.           
  18.         List<Users> userList = userDao.findUser();  
  19.           
  20.         return userList;  
  21.     }  
  22.   
  23.     @Override  
  24.     public List<Users> findUser(String loginId) {  
  25.           
  26.         List<Users> userList = userDao.findUser(loginId);  
  27.           
  28.         return userList;  
  29.     }  
  30.   
  31. }  
Java代码   收藏代码
  1. action  
  •  UserAction.action
Java代码   收藏代码
  1. package cn.net.comsys.ut.action;  
  2.   
  3. import java.util.List;  
  4.   
  5. import javax.annotation.Resource;  
  6.   
  7. import cn.net.comsys.ut.model.Users;  
  8. import cn.net.comsys.ut.service.interfaces.IUserService;  
  9.   
  10. import com.opensymphony.xwork2.ActionSupport;  
  11.   
  12. public class UserAction extends ActionSupport {  
  13.   
  14.     /** 
  15.      * serialVersionUID 
  16.      */  
  17.     private static final long serialVersionUID = 1L;  
  18.     @Resource  
  19.     private IUserService userService;  
  20.     private List<Users> userList;  
  21.     public String doUser() {  
  22.           
  23.         userList = userService.findUser();  
  24.         return SUCCESS;  
  25.     }  
  26.   
  27.     public List<Users> getUserList() {  
  28.         return userList;  
  29.     }  
  30.     public void setUserList(List<Users> userList) {  
  31.         this.userList = userList;  
  32.     }  
  33.       
  34. }  
 
   4.页面
  • user.jsp
Jsp代码   收藏代码
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"  
  2.     pageEncoding="UTF-8"%>  
  3. <%@ taglib prefix="s" uri="/struts-tags" %>  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  5. <html>  
  6. <head>  
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  8. <title>用户</title>  
  9. </head>  
  10. <body>  
  11.     <table border="1">  
  12.         <s:iterator value="userList">  
  13.             <tr>  
  14.                 <td><s:property value="loginId"/> </td>  
  15.                 <td>  
  16.                     <s:iterator value="role">  
  17.                         <s:property value="roleName"/>  
  18.                     </s:iterator>  
  19.                 </td>  
  20.             </tr>  
  21.         </s:iterator>  
  22.     </table>  
  23.     <s:debug></s:debug>  
  24. </body>  
  25. </html>  

5.结果

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本微信小程序医院挂号预约系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此微信小程序医院挂号预约系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。微信小程序医院挂号预约系统有管理员,用户两个角色。管理员功能有个人中心,用户管理,医生信息管理,医院信息管理,科室信息管理,预约信息管理,预约取消管理,留言板,系统管理。微信小程序用户可以注册登录,查看医院信息,查看医生信息,查看公告资讯,在科室信息里面进行预约,也可以取消预约。微信小程序医院挂号预约系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值