CRM代码片段

来源:互联网 发布:apple mac book pro 编辑:程序博客网 时间:2024/06/02 02:50

1.代码结构

JAR包:





2.pojo   

sysRole.java

package com.pojo;import java.util.HashSet;import java.util.Set;/** * SysRole entity. @author MyEclipse Persistence Tools */public class SysRole  implements java.io.Serializable {    // Fields         private Integer roleId;     private String roleName;     private String roleDesc;     private Byte roleFlag;     private Set sysRights = new HashSet(0);     private Set sysUsers = new HashSet(0);    // Constructors    /** default constructor */    public SysRole() {    }/** minimal constructor */    public SysRole(Integer roleId, String roleName, Byte roleFlag) {        this.roleId = roleId;        this.roleName = roleName;        this.roleFlag = roleFlag;    }        /** full constructor */    public SysRole(Integer roleId, String roleName, String roleDesc, Byte roleFlag, Set sysRights, Set sysUsers) {        this.roleId = roleId;        this.roleName = roleName;        this.roleDesc = roleDesc;        this.roleFlag = roleFlag;        this.sysRights = sysRights;        this.sysUsers = sysUsers;    }       // Property accessors    public Integer getRoleId() {        return this.roleId;    }        public void setRoleId(Integer roleId) {        this.roleId = roleId;    }    public String getRoleName() {        return this.roleName;    }        public void setRoleName(String roleName) {        this.roleName = roleName;    }    public String getRoleDesc() {        return this.roleDesc;    }        public void setRoleDesc(String roleDesc) {        this.roleDesc = roleDesc;    }    public Byte getRoleFlag() {        return this.roleFlag;    }        public void setRoleFlag(Byte roleFlag) {        this.roleFlag = roleFlag;    }    public Set getSysRights() {        return this.sysRights;    }        public void setSysRights(Set sysRights) {        this.sysRights = sysRights;    }    public Set getSysUsers() {        return this.sysUsers;    }        public void setSysUsers(Set sysUsers) {        this.sysUsers = sysUsers;    }}


3.Dao层

package com.dao;import java.io.Serializable;import java.util.List;import org.hibernate.criterion.DetachedCriteria;import com.bean.Page;/** *  * @author laukei * * @param <T> */public interface ICommonDao<T> {/** * 分页查询 * @param hql * @param page * @return */public List<T> findByPage(DetachedCriteria dc,Page<T> page);/** * 计算总记录数 * @param hql * @return */public int getCount(DetachedCriteria dc);/** * 查询所有 * @return */public List<T> list(DetachedCriteria dc);/** * 获取某个对象 */public T get(DetachedCriteria dc);/** * 获取所有对象 * @param hql * @return */public List<T> list(String hql);/** * 通过ID查询对象 * @param clazz * @param id * @return */public T getById(Class<T> clazz,Serializable id);/** * 修改对象 * @param o */public void update(T o);/** * 增加对象 * @param o * @return */public Serializable save(T o);}

4.Dao层实现类

package com.dao.impl;import java.io.Serializable;import java.sql.SQLException;import java.util.List;import org.hibernate.Criteria;import org.hibernate.HibernateException;import org.hibernate.Session;import org.hibernate.criterion.DetachedCriteria;import org.springframework.orm.hibernate3.HibernateCallback;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import com.bean.Page;import com.dao.ICommonDao;/** *  * @author laukei * * @param <T> */public class CommonDaoImpl<T> extends HibernateDaoSupport implements ICommonDao<T> {/* * (non-Javadoc) * @see com.dao.ICommonDao#findByPage(org.hibernate.criterion.DetachedCriteria, com.bean.Page) */public List<T> findByPage(final DetachedCriteria dc, final Page<T> page) {@SuppressWarnings("unchecked")List<T> all=this.getHibernateTemplate().executeFind(new HibernateCallback<List<T>>() {public List<T> doInHibernate(Session session)throws HibernateException, SQLException {//内部类中的方法要访问外部类的局部变量需要在外部类的局部变量之前加入final,方可访问Criteria criteria=dc.getExecutableCriteria(session);criteria.setFirstResult((page.getCurrentPage()-1)*page.getLineSize());criteria.setMaxResults(page.getLineSize());return criteria.list() ;}});return all;}public int getCount(final DetachedCriteria dc) {int count=this.getHibernateTemplate().execute(new HibernateCallback<Integer>() {public Integer doInHibernate(Session session)throws HibernateException, SQLException {Criteria criteria=dc.getExecutableCriteria(session);Integer temp=(Integer) criteria.uniqueResult();return temp;}});return count;}public List<T> list(String hql) {@SuppressWarnings("unchecked")List<T> all=this.getHibernateTemplate().find(hql);return all;}public T get(final DetachedCriteria dc) {T o= this.getHibernateTemplate().execute(new HibernateCallback<T>() {public T doInHibernate(Session session) throws HibernateException,SQLException {Criteria criteria=dc.getExecutableCriteria(session);@SuppressWarnings("unchecked")T temp=(T) criteria.uniqueResult();return temp;}});return o;}public T getById(Class<T> clazz, Serializable id) {return this.getHibernateTemplate().get(clazz, id);}public List<T> list(final DetachedCriteria dc) {@SuppressWarnings("unchecked")List<T> all= this.getHibernateTemplate().executeFind(new HibernateCallback<List<T>>() {public List<T> doInHibernate(Session session) throws HibernateException,SQLException {Criteria criteria=dc.getExecutableCriteria(session);List<T> temp=criteria.list();return temp;}});return all;}public void update(T o) {this.getHibernateTemplate().update(o);}public Serializable save(T o) {return this.getHibernateTemplate().save(o);}}


5.service层

接口:
package com.service;import com.bean.Page;import com.pojo.SysRole;public interface IRoleService {/* * 通过ID查找角色 */public SysRole findRoleById(int roleId);/* * 分页角色列表 */public Page<SysRole> findRoles(SysRole sysRole,Page<SysRole> page);/* * 授权角色 */public boolean assignRight(int rid,String mids); /* * 增加角色 */public boolean addRole(SysRole sysRole);/* * 删除角色 */public boolean delRole(Integer roleId);/* * 编辑角色 */public boolean editRole(SysRole sysRole);}

实现类:
package com.service.impl;import java.io.Serializable;import java.util.List;import java.util.Set;import org.hibernate.criterion.DetachedCriteria;import org.hibernate.criterion.Property;import org.hibernate.criterion.Restrictions;import com.bean.Page;import com.dao.ICommonDao;import com.pojo.SysRight;import com.pojo.SysRole;import com.service.IRoleService;public class RoleServiceImpl implements IRoleService {private ICommonDao<SysRole> sysRoleDao;private ICommonDao<SysRight> sysRightDao;public void setSysRightDao(ICommonDao<SysRight> sysRightDao) {this.sysRightDao = sysRightDao;}public void setSysRoleDao(ICommonDao<SysRole> sysRoleDao) {this.sysRoleDao = sysRoleDao;}/** * 通过ID查询角色信息 */public SysRole findRoleById(int roleId) {return this.sysRoleDao.getById(SysRole.class,roleId);}/* * 分页查询 */public Page<SysRole> findRoles(SysRole sysRole, Page<SysRole> page) {if (page==null) {page=new Page<SysRole>();}DetachedCriteria listdc=DetachedCriteria.forClass(SysRole.class).add(Restrictions.eq("roleFlag", (byte)1));DetachedCriteria countdc=DetachedCriteria.forClass(SysRole.class);countdc.setProjection(Property.forName("roleId").count()).add(Restrictions.eq("roleFlag", (byte)1));if (sysRole!=null) {if (sysRole.getRoleName()!= null && !"".equals(sysRole.getRoleName())) {listdc.add(Restrictions.like("roleName","%"+sysRole.getRoleName()+"%"));countdc.add(Restrictions.like("roleName","%"+sysRole.getRoleName()+"%"));}}List<SysRole> list = this.sysRoleDao.findByPage(listdc, page);int count = this.sysRoleDao.getCount(countdc);page.setList(list);page.setCount(count);return page;}public boolean assignRight(int rid, String mids) {//通过角色id查询角色信息SysRole role=this.sysRoleDao.getById(SysRole.class, rid);//获取稳修改前该角色所拥有的权限@SuppressWarnings("unchecked")Set<SysRight> rights= role.getSysRights();//清空之前所有的权限rights.clear();//拆分字符串if (mids!=null) {String[] midArray=mids.split(",");for (String mid : midArray) {DetachedCriteria dc=DetachedCriteria.forClass(SysRight.class);dc.add(Restrictions.eq("rightCode", mid));SysRight right=this.sysRightDao.get(dc);//重新添加到集合中rights.add(right);}}//如上操作都是在内存中逻辑完成的try {this.sysRoleDao.update(role);return true;} catch (Exception e) {e.printStackTrace();}return false;}/* *增加角色 */public boolean addRole(SysRole sysRole) {Serializable id=this.sysRoleDao.save(sysRole);if (id!=null) {return true;}return false;}/* * 删除角色 */public boolean delRole(Integer roleId) {SysRole role=this.sysRoleDao.getById(SysRole.class, roleId);role.setRoleFlag((byte)0);try {this.sysRoleDao.update(role);return true;} catch (Exception e) {e.printStackTrace();}return false;}/* * 编辑角色 */public boolean editRole(SysRole sysRole) {sysRole.setRoleFlag((byte)1);try {this.sysRoleDao.update(sysRole);return true;} catch (Exception e) {e.printStackTrace();}return false;}}

6.Action层

package com.action;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;import com.bean.Page;import com.opensymphony.xwork2.ActionSupport;import com.pojo.SysRole;import com.service.IRoleService;public class RoleAction extends ActionSupport {private IRoleService roleService;private SysRole role;private int page=1;private int rows=5;private int rid;private String mids; private Integer roleId;private Map<String,Object> dataMap;public Integer getRoleId() {return roleId;}public void setRoleId(Integer roleId) {this.roleId = roleId;}public int getRid() {return rid;}public void setRid(int rid) {this.rid = rid;}public String getMids() {return mids;}public void setMids(String mids) {this.mids = mids;}public SysRole getRole() {return role;}public void setRole(SysRole role) {this.role = role;}public int getPage() {return page;}public void setPage(int page) {this.page = page;}public int getRows() {return rows;}public void setRows(int rows) {this.rows = rows;}public Map<String, Object> getDataMap() {return dataMap;}public void setDataMap(Map<String, Object> dataMap) {this.dataMap = dataMap;}public void setRoleService(IRoleService roleService) {this.roleService = roleService;}public String list(){Page<SysRole> p=new Page<SysRole>();p.setCurrentPage(page);p.setLineSize(rows);p=roleService.findRoles(role,p);List<SysRole> roles=p.getList();List<SysRole> roleAll=new ArrayList<SysRole>();for (SysRole sysRole : roles) {SysRole role=new SysRole();role.setRoleId(sysRole.getRoleId());role.setRoleName(sysRole.getRoleName());role.setRoleFlag(sysRole.getRoleFlag());role.setRoleDesc(sysRole.getRoleDesc());roleAll.add(role);}dataMap=new HashMap<String,Object>();//如果要使用easyui,要传递记录数,必须要使用key为totaldataMap.put("total",p.getCount());//如果要使用easyui,向前台传递数据,那么集合必须是key为rowsdataMap.put("rows",roleAll);return SUCCESS;}public String updateRight(){boolean flag=this.roleService.assignRight(rid, mids);dataMap=new HashMap<String, Object>();if (flag) {dataMap.put("msg", "success");}else {dataMap.put("msg", "faliure");}return "assignRight";}/* * 增加 角色 */public String addRole(){role.setRoleFlag((byte)1);boolean flag=this.roleService.addRole(role);dataMap=new HashMap<String, Object>();if (flag) {dataMap.put("msg", "success");}else {dataMap.put("msg", "faliure");}return "addRole";}/* * 删除角色 */public String delRole(){boolean flag=this.roleService.delRole(roleId);dataMap=new HashMap<String,Object>();if(flag){dataMap.put("msg","success");}else{dataMap.put("msg","faliure");}return "delRole";}/* * 修改角色 */public String updataRole(){boolean flag=this.roleService.editRole(role);dataMap=new HashMap<String,Object>();if(flag){dataMap.put("msg","success");}else{dataMap.put("msg","faliure");}return "updateRole";}}

7.Bean类

package com.bean;import java.util.Map;public class Node {private String id;private String text;private String state;private boolean checked;private Map<String,Object> attributes;//自定义属性public boolean isChecked() {return checked;}public void setChecked(boolean checked) {this.checked = checked;}public String getId() {return id;}public void setId(String id) {this.id = id;}public String getText() {return text;}public void setText(String text) {this.text = text;}public String getState() {return state;}public void setState(String state) {this.state = state;}public Map<String, Object> getAttributes() {return attributes;}public void setAttributes(Map<String, Object> attributes) {this.attributes = attributes;}}



package com.bean;import java.util.List;/** * 分页 */public class Page<T>{private int currentPage=1;//当前页private int lineSize=5;//每页的跨度private int count;//总记录数private int totalPage;//总页数private List<T> list;//集合public int getCurrentPage() {return currentPage;}public void setCurrentPage(int currentPage) {this.currentPage = currentPage;}public int getLineSize() {return lineSize;}public void setLineSize(int lineSize) {this.lineSize = lineSize;}public int getCount() {return count;}public void setCount(int count) {this.count = count;}public int getTotalPage(int count,int lineSize) {if(count%lineSize==0){return count/lineSize;}else{return count/lineSize+1;}}public void setTotalPage(int totalPage) {this.totalPage = totalPage;}public List<T> getList() {return list;}public void setList(List<T> list) {this.list = list;}}



8.XML配置

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:p="http://www.springframework.org/schema/p"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.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property><property name="url" value="jdbc:oracle:thin:locahost:1521:orcl"></property><property name="username" value="laukei"></property><property name="password" value="laukei"></property></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop></props></property><property name="mappingResources"><list><value>com/pojo/BasicDictionary.hbm.xml</value><value>com/pojo/SaleChance.hbm.xml</value><value>com/pojo/SysUser.hbm.xml</value><value>com/pojo/Product.hbm.xml</value><value>com/pojo/SysRight.hbm.xml</value><value>com/pojo/Storage.hbm.xml</value><value>com/pojo/Orders.hbm.xml</value><value>com/pojo/OrdersLine.hbm.xml</value><value>com/pojo/ServiceManager.hbm.xml</value><value>com/pojo/CustLost.hbm.xml</value><value>com/pojo/CustLinkman.hbm.xml</value><value>com/pojo/SysRole.hbm.xml</value><value>com/pojo/SalePlan.hbm.xml</value><value>com/pojo/CommunicateRecord.hbm.xml</value><value>com/pojo/CustCustomer.hbm.xml</value></list></property></bean><bean id="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory"><ref bean="sessionFactory" /></property></bean><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="find*" propagation="NOT_SUPPORTED"read-only="true" /><tx:method name="get*" propagation="NOT_SUPPORTED"read-only="true" /><tx:method name="*" propagation="REQUIRED" /></tx:attributes></tx:advice><aop:config><aop:pointcut expression="execution(public * com.service.impl.*.*(..))"id="pc" /><aop:advisor advice-ref="txAdvice" pointcut-ref="pc" /></aop:config><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><property name="sessionFactory"><ref bean="sessionFactory" /></property></bean><bean id="commonDao" class="com.dao.impl.CommonDaoImpl"><property name="hibernateTemplate"><ref bean="hibernateTemplate" /></property></bean><bean id="basicDictionaryService" class="com.service.impl.BasicDictionaryServiceImpl"><property name="basicDictionaryDao"><ref bean="commonDao" /></property></bean><bean id="productService" class="com.service.impl.ProductServiceImpl"><property name="productDao"><ref bean="commonDao" /></property></bean><bean id="storageService" class="com.service.impl.StorageServiceImpl"><property name="strorageDao"><ref bean="commonDao" /></property><property name="productDao"><ref bean="commonDao" /></property></bean><bean id="saleService" class="com.service.impl.SaleServiceImpl"><property name="salePlanDao"><ref bean="commonDao" /></property><property name="saleChanceDao"><ref bean="commonDao" /></property></bean><bean id="userService" class="com.service.impl.SysUesrServiceImpl"><property name="sysUserDao"><ref bean="commonDao" /></property><property name="sysRoleDao"><ref bean="commonDao" /></property></bean><bean id="rightService" class="com.service.impl.RightServiceImpl"><property name="sysRightDao"><ref bean="commonDao" /></property></bean><bean id="roleService" class="com.service.impl.RoleServiceImpl"><property name="sysRoleDao"><ref bean="commonDao" /></property><property name="sysRightDao"><ref bean="commonDao" /></property></bean><bean id="customerService" class="com.service.impl.CustCustomerServiceImpl"><property name="custCustomerDao"><ref bean="commonDao" /></property><property name="custLostDao"><ref bean="commonDao" /></property></bean><bean id="ServManageDao" class="com.service.impl.ServiceServiceImpl"><property name="sercManagerDao"><ref bean="commonDao"/></property><property name="sercByCustDao"><ref bean="commonDao"/></property><property name="serByBasicDao"><ref bean="commonDao"/></property><property name="serviceUser"><ref bean="commonDao"/></property></bean><bean id="basicDictionaryAction" class="com.action.BasicDictionaryAction"scope="prototype"><property name="basicDictionaryService"><ref bean="basicDictionaryService" /></property></bean><bean id="productAction" class="com.action.ProductAction" scope="prototype"><property name="productService"><ref bean="productService" /></property></bean><bean id="storageAction" class="com.action.StorageAction" scope="prototype"><property name="storageService"><ref bean="storageService" /></property></bean><bean id="saleAction" class="com.action.SaleAction" scope="prototype"><property name="saleService"><ref bean="saleService" /></property></bean><bean id="userAction" class="com.action.SysUserAction" scope="prototype"><property name="userService"><ref bean="userService" /></property><property name="rightService"><ref bean="rightService"/></property><property name="roleService"><ref bean="roleService"/></property></bean><bean id="customerAction" class="com.action.CustomerAction" scope="prototype"><property name="customerService"><ref bean="customerService" /></property><property name="custLostService"><ref bean="customerService" /></property></bean><bean id="roleAction" class="com.action.RoleAction" scope="prototype"><property name="roleService"><ref bean="roleService" /></property></bean><bean id="ServiceActionDao" class="com.action.ServiceAction" scope="prototype"><property name="managerService"><ref bean="ServManageDao"/></property></bean></beans>

struts.xml
<?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.devMode" value="true"></constant><package name="default" namespace="/" extends="json-default"><action name="basicDictionaryAction" class="basicDictionaryAction"><result type="json"><param name="root">dataMap</param></result><result name="addBasic" type="json"><param name="root">dataMap</param></result><result name="delBasic" type="json"><param name="root">dataMap</param></result><result name="editBasic" type="json"><param name="root">dataMap</param></result><result name="getById" type="json"><param name="root">basicDictionary</param></result></action><action name="productAction" class="productAction"><result type="json"><param name="root">proMap</param></result><result name="addProduct" type="json"><param name="root">proMap</param></result><result name="delProduct" type="json"><param name="root">proMap</param></result><result name="editProduct" type="json"><param name="root">proMap</param></result><result name="getById" type="json"><param name="root">product</param></result></action><action name="storageAction" class="storageAction"><result type="json"><param name="root">StoMap</param></result><result name="products" type="json"><param name="root">products</param></result></action><action name="saleAction" class="saleAction"><result type="json"><param name="root">dataMap</param></result><result name="addSaleCh" type="json"><param name="root">dataMap</param></result><result name="delSaleCh" type="json"><param name="root">dataMap</param></result><result name="getSaleCh" type="json"><param name="root">saleChance</param></result><result name="updateSaleCh" type="json"><param name="root">dataMap</param></result><result name="assignSaleCh" type="json"><param name="root">dataMap</param></result><result name="addSalePl" type="json"><param name="root">dataMap</param></result><result name="getPlan" type="json"><param name="root">dataMap</param></result><result name="listSP" type="json"><param name="root">dataMap</param></result><result name="delSaleSP" type="json"><param name="root">dataMap</param></result><result name="updateSaleSP" type="json"><param name="root">dataMap</param></result><result name="goodSt" type="json"><param name="root">dataMap</param></result><result name="stopSt" type="json"><param name="root">dataMap</param></result><result name="upChan" type="json"><param name="root">saleChance</param></result><result name="updaItem" type="json"><param name="root">dataMap</param></result></action><action name="userAction" class="userAction"><result type="json"><param name="root">user</param></result><result name="loadTree" type="json">      <param name="root">nodes</param></result><result name="users" type="json">      <param name="root">users</param></result><result name="list" type="json">      <param name="root">dataMap</param></result><result name="addUser" type="json">      <param name="root">dataMap</param></result><result name="delUser" type="json">      <param name="root">dataMap</param></result><result name="updateUser" type="json">      <param name="root">dataMap</param></result><result name="getById" type="json">      <param name="root">user</param></result><result name="findSysRole" type="json">      <param name="root">sysRoles</param></result></action><action name="customerAction" class="customerAction"><result type="json"><param name="root">dataMap</param></result></action><action name="roleAction" class="roleAction"><result name="addRole"  type="json"><param name="root">dataMap</param></result><result type="json"><param name="root">dataMap</param></result><result name="assignRight" type="json"><param name="root">dataMap</param></result><result name="delRole" type="json">      <param name="root">dataMap</param></result><result name="updateRole" type="json">      <param name="root">dataMap</param></result></action><action name="managerAction" class="ServiceActionDao"><result type="json"><param name="root">dataMap</param></result><result name="byBaType" type="json"><param name="root">basB</param></result><result name="byBaStatus" type="json"><param name="root">basB</param></result><result name="addServ" type="json"><param name="root">dataMap</param></result><result name="findUser" type="json"><param name="root">user</param></result><result name="fP" type="json"><param name="root">dataMap</param></result><result name="deleSer" type="json"><param name="root">dataMap</param></result><result name="chuli" type="json"><param name="root">dataMap</param></result><result name="fankui" type="json"><param name="root">dataMap</param></result><result name="guidang" type="json"><param name="root">dataMap</param></result><result name="servChuLi" type="json"><param name="root">dataMap</param></result><result name="servFankui" type="json"><param name="root">dataMap</param></result></action><action name="custcuAction" class="ServiceActionDao"><result type="json"><param name="root">customers</param></result></action></package></struts>    


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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">  <display-name></display-name>  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:applicationContext.xml</param-value>  </context-param>  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <filter>    <filter-name>characterEncodingFilter</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>    <init-param>      <param-name>forceEncoding</param-name>      <param-value>true</param-value>    </init-param>  </filter>  <filter-mapping>    <filter-name>characterEncodingFilter</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>  <welcome-file-list>    <welcome-file>login.jsp</welcome-file>  </welcome-file-list>  <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></web-app>

9.JSP页面

role.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><base href="<%=basePath%>"><title>角色管理</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><link rel="stylesheet"href="script/jquery-easyui-1.4.5/themes/metro-blue/easyui.css"type="text/css"></link><link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/icon.css"type="text/css"></link><link rel="stylesheet"href="script/jquery-easyui-1.4.5/themes/color.css" type="text/css"></link><script type="text/javascript"src="script/jquery-easyui-1.4.5/jquery.min.js"></script><script type="text/javascript"src="script/jquery-easyui-1.4.5/jquery.easyui.min.js"></script><script type="text/javascript">$(function() {//表格主体信息$('#dg').datagrid({url : '${pageContext.request.contextPath}/roleAction!list',fitColumns : true,pagination : true,toolbar : '#page_role_management_tb',rownumbers : true,loadMsg : '数据装载中......',columns : [ [ {field : 'roleId',title : '角色编号',width : 150,checkbox : true}, {field : 'roleName',title : '角色名称',width : 150}, {field : 'roleDesc',title : '角色描述',width : 150}, {field : 'roleFlag',title : '角色状态',width : 150,formatter : function(value, row, index) {if (value == '1') {return '正常';} else if (value == '0') {return '非正常';}}}, ]]});$('#dg').datagrid('getPager').pagination({pageSize : 10,pageList : [ 3, 5, 10, 15, 20 ],beforePageText : '第',afterPageText : '页    共 {pages} 页',displayMsg : '当前显示 {from} - {to} 条记录   共 {total} 条记录'});//授权按钮 $("#tb_grant").click(function() {var rows = $('#dg').datagrid('getChecked');if (rows.length == 0) {$.messager.show({title : '提示',msg : '请勾选要授权的角色!'});} else {if (rows.length > 1) {$.messager.show({title : '提示',msg : '授权时只能选择一个角色!'});} else if (rows.length == 1) {var rId = rows[0].roleId;assignRight(rId);$("#win").dialog('open');}}});$("#tb_add").click(function() {$("#addWindow").window("open");});$("#addBtn").click(function() {$.post("roleAction!addRole", $("#myForm").serialize(),function(data) {if (data.msg == "success") {$("#addWindow").window("close");$("#dg").datagrid("load");}}, "json");});//删除角色$("#tb_remove").click(function() {var rows = $('#dg').datagrid('getChecked');if (rows.length == 0) {$.messager.show({title : '提示',msg : '请勾选要删除的角色!'});} else  if (rows.length == 1) {var roleId = rows[0].roleId;$.messager.confirm("删除","您确认要删除记录吗?",function(data) {if (data!=null) {$.post("roleAction!delRole",{"roleId":roleId},function(data){if(data.msg=="success"){$("#dg").datagrid("load");}},"json");};});}});//修改角色    $("#tb_edit").click(function(){    var rows=$("#dg").datagrid("getChecked");    if(rows.length==0){    $.messager.show({    title:'提示',    msg:'请勾选修改对象!',    });    }else if(rows.length>1){    $.messager.show({    title:'提示',    msg:'每次只能修改一个对象',    });    }else{    $("#editWindow").window("open");    var str="role.roleId*role.roleName*role.roleDesc";var arr=str.split('*');document.getElementById('d1').value=rows[0].roleId;document.getElementById('d2').value=rows[0].roleName;document.getElementById('d3').value=rows[0].roleDesc;    }    });    $("#editBtn").click(function(){    $.post("roleAction!updataRole",$("#updateForm").serialize(),function(data){    alert(data);    if(data.msg=="success"){    $("#editWindow").window("close");    $("#dg").datagrid("load");    }    },"json");    });    //查询操作$("#searchBtn").click(function(){$("#dg").datagrid('load',{"role.roleName":$("#roleName").val()});});});function assignRight(rId) {//加载内容$("#tt").tree({url : "userAction!assignTree?roleId=" + rId,lines : true,checkbox : true,animate : true,//页面加载完数据之后触发onLoadSuccess : function() {//展开所有菜单$(this).tree("expandAll");}});}</script><style type="text/css">  #me{  font-size: 12px;  }  input{font-size: 12px;}  </style></head><body><div id="me"><input id="roleName" type="text" class="easyui-validatebox">  <a id="searchBtn" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询角色</a>  </div><div id="page_role_management_tb"><a class="easyui-linkbutton" id="tb_remove"data-options="iconCls:'icon-remove',plain:true" style="float:right;">删除</a><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_edit"data-options="iconCls:'icon-edit',plain:true" style="float:right;">编辑</a><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_add"data-options="iconCls:'icon-add',plain:true" style="float:right;">增加</a><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_grant"data-options="iconCls:'icon-edit',plain:true" style="float:right;">授权</a><div class="datagrid-btn-separator"></div></div><table id="dg"></table><div id="win" class="easyui-dialog" title="角色授权"style="width:300px;height:500px"data-options="iconCls:'icon-save',modal:true,closed:true,buttons:[{text:'保存',handler:function(){var ids=[];var nodes =$('#tt').tree('getChecked', ['checked','indeterminate']);$.each(nodes,function(key,val){ids.push(val.id);});    var mIds=ids.join(',');    var rows=$('#dg').datagrid('getChecked');    var rId=rows[0].roleId;    $.ajax({url:'roleAction!updateRight',data:{rid:rId,mids:mIds},dataType:'json',type:'POST',success:function(data){if(data.msg=='success'){$('#win').dialog('close');}}});}},{text:'关闭',handler:function(){$('#win').dialog('close');}}]"><ul id="tt"></ul></div><div id="addWindow" class="easyui-window" title="增加角色"style="width:200px;height:150px"data-options="iconCls:'icon-save',modal:true,closed:true"><form id="myForm">角色名称<input type="text" name="role.roleName"><br> 角色描述<input type="text" name="role.roleDesc"><br> <input type="button" value="增加" id="addBtn"></form></div><!-- 修改操作窗口 -->    <div id="editWindow" class="easyui-window" title="修改角色数据" style="width:100px;width:auto"           data-options="iconCls:'icon-edit',modal:true,closed:true">        <form id="updateForm" method="post">        <table>      <tr>    <td>角色编号</td>    <td><input type="text" name="role.roleId" id="d1" readonly="readonly"></td>    </tr>    <tr>    <td>角色名称</td>    <td><input type="text" name="role.roleName" id="d2"></td>    </tr>    <tr>    <td>角色描述</td>    <td><textarea rows="5" cols="17" name="role.roleDesc" id="d3" ></textarea></td>    </tr>    <tr>    <td align="center"><input type="button"  class="easyui-linkbutton"  value="提交"  id="editBtn" ></td>    </tr>    </table>        </form>    </div>  </body></html>


user.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>用户管理</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/metro-blue/easyui.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/icon.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/color.css" type="text/css"></link>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.min.js"></script>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>   <script type="text/javascript" src="script/jquery-easyui-1.4.5/easyloader.js"></script>  <script type="text/javascript">  $(function(){  $("#dg").datagrid({  url:"userAction!userList",  columns:[[  {field:'userId',title:'编号',width:20,checkbox : true},  {field:'sysRole.roleName',title:'角色名称',width:20,formatter: function(value,rec){  return rec.sysRole.roleName;}},  {field:'userName',title:'用户名',width:20},  {field:'userPassword',title:'密码',width:20,hidden:true},  ]],  striped:true,  fitColumns:true,  pagination:true  });  $("#dg").datagrid('getPager').pagination({pageSize:10,pageList : [3,5,10,15,20],beforePageText: '第',afterPageText: '页    共 {pages} 页',displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'  });//查询操作$("#searchBtn").click(function(){$("#dg").datagrid('load',{"user.userName":$("#userName").val(),"user.userId":$("#userId").val()});});  //增加操作    $("#add").click(function(){    $("#addwindow").window("open");  $("#roleId").combobox({        url:'userAction!findSysRole',        valueField:'roleId',        textField:'roleName',    onSelect:function(data){    $("#roleId").val(data.roleId);    } });     });$("#addBtn").click(function(){    $.post("userAction!addUser",$("#addForm").serialize(),function(data){    if(data.msg=="success"){    $("#addwindow").window("close");    $("#dg").datagrid("load");    }    },"json");    });    //删除    $("#remove").click(function(){    var rows=$("#dg").datagrid("getChecked");    if(rows.length==0){    $.messager.show({    title:'提示',    msg:'请勾选对象!'    });    }else if(rows.length>1){    $.messager.show({    title:'提示',    msg:'每次只能勾选一个对象',    });    }else{    if($.messager.confirm("删除","您确认要删除记录吗?")){    var userId=rows[0].userId;    $.post("userAction!delUser",{"userId":userId},function(data){    if(data.msg=="success"){    $("#dg").datagrid("load");    }    },"json");    }    }    });    //修改操作    $("#edit").click(function(){    var rows=$('#dg').datagrid("getChecked");    if(rows.length==0){    $.messager.show({    title:'提示',    msg:'请勾选对象!',    });    }else if(rows.length>1){    $.messager.show({    title:'提示',    msg:'每次只能勾选一个对象',    });    }else{    $("#editWindow").window("open");      var pro_string="user.userId*user.userName*user.userPassword*user.userFlag*user.role.roleId";var arr=pro_string.split('*');document.getElementById('d1').value=rows[0].userId;document.getElementById('d2').value=rows[0].userName;document.getElementById('d3').value=rows[0].userPassword;document.getElementById('d4').value=rows[0].userFlag;document.getElementById('d4').value=rows[0].sysRole.roleId;//roleId获取  $("#d5").combobox({        url:'userAction!findSysRole',        valueField:'roleId',        textField:'roleName',    onSelect:function(data){    $("#d5").val(data.roleId);    } });     }    });//修改提交    $("#updateBtn").click(function(){    $.post("userAction!editUser",$("#updateForm").serialize(),function(data){    if(data.msg=="success"){    $("#editWindow").window("close");    $("#dg").datagrid("load");    }    },"json");    });  });    </script>  <style type="text/css">  #me{  font-size: 12px;  }  input{font-size: 12px;}  </style>  </head>   <body>  <div id="me">     <form action="#">  <input id="userName" type="text" class="easyui-validatebox">  <a id="searchBtn" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询用户</a>  <div id="page_role_management_tb">  <a class="easyui-linkbutton" id="remove" data-options="iconCls:'icon-remove',plain:true" style="float:right;">删除</a><a class="easyui-linkbutton" id="edit" data-options="iconCls:'icon-edit',plain:true" style="float:right;">编辑</a><a class="easyui-linkbutton" id="add" data-options="iconCls:'icon-add',plain:true" style="float:right;">增加</a></div>  </form>   </div>    <!-- 增加-->  <div id="addwindow" class="easyui-window" title="增加数据" style="width:280px;height:auto"           data-options="iconCls:'icon-save',modal:true,closed:true">        <form id="addForm">        <table align="center">    <tr>    <td>姓名</td>    <td><input type="text" name="user.userName" id="userName"></td>    </tr>    <tr>    <td>密码</td>    <td><input type="text" name="user.userPassword" id="userPassword"></td>    </tr>    <tr>    <td>角色</td>    <td><input type="text" name="user.sysRole.roleId" id="roleId" type="combobox"></td>    </tr>    <tr>    <td><input type="button" class="easyui-linkbutton" value="提交" id="addBtn"></td>    </tr>    </table>        </form>    </div>  <!-- 修改 -->    <div id="editWindow" class="easyui-window" title="编辑数据" style="width:300px;height:auto"           data-options="iconCls:'icon-save',modal:true,closed:true">        <form id="updateForm" method="post">        <table align="center">    <tr>    <td>编号:</td>    <td><input type="text" name="user.userId" id="d1" readonly="readonly"></td>    </tr>     <tr>    <td>姓名:</td>    <td><input type="text"  name="user.userName" id="d2"></td>    </tr>    <tr>    <td>密码:</td>    <td><input type="text"name="user.userPassword" id="d3"></td>    </tr>    <tr>    <td>标记:</td>    <td><input type="text" name="user.userFlag" id="d4"></td>    </tr>    <tr>    <td>角色Id:</td>    <td><input type="text"  name="user.sysRole.roleId" id="d5"></td>        </tr>    <tr>    <td><input type="button" class="easyui-linkbutton"  value="提交" id="updateBtn" ></td>    </tr>    </table>        </form>    </div> <table id="dg" width="100%"></table>  </body></html>


basic.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyworno,keywortype,keyworitem"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/metro-blue/easyui.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/icon.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/color.css" type="text/css"></link>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.min.js"></script>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>   <script type="text/javascript" src="script/jquery-easyui-1.4.5/easyloader.js"></script>  <script type="text/javascript">  $(function(){  $("#dg").datagrid({  url:"basicDictionaryAction!list",  columns:[[  {field:'basiNo',title:'编号',width:20,checkbox: true},  {field:'basiType',title:'类别',width:20},  {field:'basiItem',title:'条目',width:20},  {field:'basiValue',title:'值',width:20},  {field:'basiEditable',title:'是否可编辑',width:20,  formatter : function(value, row, index) {if (value == '1') {return '可以编辑';} else if (value == '0') {return '不可以编辑';}}}  ]],  striped:true,  fitColumns:true,  pagination:true,  toolbar : '#page_role_management_tb'  });  $("#dg").datagrid('getPager').pagination({pageSize:10,pageList : [3,5,10,15,20],beforePageText: '第',afterPageText: '页    共 {pages} 页',displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'  });$("#searchBtn").click(function(){$("#dg").datagrid('load',{"basicDictionary.basiType":$("#type").val(),"basicDictionary.basiItem":$("#item").val(),"basicDictionary.basiValue":$("#valu").val()});});//增加    $("#tb_add").click(function(){    $("#addwindow").window("open");    });$("#addBtn").click(function(){    $.post("basicDictionaryAction!addBasic",$("#addForm").serialize(),function(data){    if(data.msg=="success"){    $("#addwindow").window("close");    $("#dg").datagrid("load");    }    },"json");    });//删除    $("#tb_remove").click(function(){    var rows=$("#dg").datagrid("getChecked");    if(rows.length==0){    $.messager.show({    title:'提示',    msg:'请勾选要删除的记录!'    });    }else if(rows.length>1){    $.messager.show({    title:'提示',    msg:'每次只允许删除一条记录',    });    }else if(rows.length==1){    $.messager.confirm("删除","您确认要删除记录吗?");    var basiNo=rows[0].basiNo;    $.post("basicDictionaryAction!delBasic",{"basiNo":basiNo},function(data){    if(data.msg=="success"){    $("#dg").datagrid("load");    }    },"json");    }    });//修改    $("#tb_edit").click(function(){    var rows=$('#dg').datagrid("getChecked");    if(rows.length==0){    $.messager.show({    title:'提示',    msg:'请选择修改的记录!',    });    }else if(rows.length>1){    $.messager.show({    title:'提示',    msg:'每次只能修改一条记录',    });    }else{    var str="basicDictionary.basiNo*basicDictionary.basiType*basicDictionary.basiItem*basicDictionary.basiValue*basicDictionary.basiEditable*basicDictionary.basiFlag";var arr=str.split('*');document.getElementById('bno').value=rows[0].basiNo;document.getElementById('btype').value=rows[0].basiType;document.getElementById('bitem').value=rows[0].basiItem;document.getElementById('bvalu').value=rows[0].basiValue;document.getElementById('beditable').value=rows[0].basiEditable;document.getElementById('bflag').value=rows[0].basiFlag;    $("#editwindow").window("open");    }    });    $("#editBtn").click(function(){    $.post("basicDictionaryAction!editBasic",$("#editForm").serialize(),function(data){    if(data.msg=="success"){    $("#editwindow").window("close");    $("#dg").datagrid("load");    }    },"json");    });});  </script>  <style type="text/css">  #me{  font-size: 12px;  }  input{font-size: 12px;}  </style> </head>  <body>  <div id="page_role_management_tb"><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_add"data-options="iconCls:'icon-add',plain:true" style="float:right;">增加</a><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_remove"data-options="iconCls:'icon-remove',plain:true" style="float:right;">删除</a><div class="datagrid-btn-separator"></div><a class="easyui-linkbutton" id="tb_edit"data-options="iconCls:'icon-edit',plain:true" style="float:right;">编辑</a><div class="datagrid-btn-separator"></div><a href="help.jsp" class="easyui-linkbutton" id="help"data-options="iconCls: 'icon-help',plain:true" onclick="help('');"style="float:right;margin-right: 1px;">帮助</a></div><div id="me">  <form action="#">  类别 <input id="type" type="text" class="easyui-validatebox">  条目 <input id="item" type="text" class="easyui-validatebox">  值 <input id="valu" type="text" class="easyui-validatebox">  <a id="searchBtn" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>  </form>  </div>  <div id="addwindow" class="easyui-window" title="增加数据" style="width:280px;height:auto"           data-options="iconCls:'icon-add',modal:true,closed:true">        <form id="addForm">        <table align="center">      <tr>    <td>编号:</td>    <td><input type="text" name="basicDictionary.basiNo"></td>    </tr>    <tr>    <td>类别:</td>    <td><input type="text" name="basicDictionary.basiType" ></td>    </tr>    <tr>    <td>条目:</td>    <td><input type="text" name="basicDictionary.basiItem"></td>    </tr>    <tr>    <td>值:</td>    <td><input  type="text" name="basicDictionary.basiValue"></td>    </tr>    <tr>    <td><input type="button" value="提交" class="easyui-linkbutton"  id="addBtn"></td>    </tr>    </table>        </form>    </div>        <div id="editwindow" class="easyui-window" title="编辑数据" style="width:280px;height:auto"           data-options="iconCls:'icon-edit',modal:true,closed:true">        <form id="editForm">        <table align="center">      <tr>    <td>编号</td>    <td><input type="text" name="basicDictionary.basiNo" id="bno" readonly></td>    </tr>    <tr>    <td>类别</td>    <td><input type="text" name="basicDictionary.basiType" id="btype"></td>    </tr>    <tr>    <td>条目</td>    <td><input type="text" name="basicDictionary.basiItem" id="bitem"></td>    </tr>    <tr>    <td>值</td>    <td><input  type="text" name="basicDictionary.basiValue" id="bvalu"></td>    </tr>    <tr>    <td>是否可编辑</td>    <td><input type="text" name="basicd.basiEditable" id="beditable" readonly></td>    </tr>    <tr>    <td>状态</td>    <td><input type="text" name="basicd.basiFlag" id="bflag" readonly></td>    </tr>    <tr>    <td><input type="button" value="提交" class="easyui-linkbutton"  id="editBtn"></td>    </tr>    </table>        </form>    </div> <table id="dg" width="90%" align="center"></table>  </body></html>

index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@page import="java.text.SimpleDateFormat"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</title>    <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/metro-blue/easyui.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/icon.css" type="text/css"></link>  <link rel="stylesheet" href="script/jquery-easyui-1.4.5/themes/color.css" type="text/css"></link>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.min.js"></script>  <script type="text/javascript" src="script/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>   <script type="text/javascript" src="script/jquery-easyui-1.4.5/easyloader.js"></script>  <script type="text/javascript">  $(function(){  $("#treemenu").tree({  url:"userAction!loadTree?roleId="+'${sessionScope.user.sysRole.roleId}',  lines:true,  animate:true,  onClick:function(node){  if(node.attributes.url==null){  if(node.state=="closed"){  $(this).tree('expand',node.target);  }else if(node.state=="open"){$(this).tree('collapse',node.target);}  }else{  //alert(node.attributes.url);  addTab(node.text,node.attributes.url);  }  },  //页面加载完数据之后触发  onLoadSuccess:function(){  //展开所有菜单$(this).tree("expandAll");  }    });  });  function addTab(title,url){  if ($("#tabs").tabs('exists',title)) {$("#tabs").tabs('select',title);}else{$('#tabs').tabs('add',{        title:title,        content:'<iframe src="'+'${pageContext.request.contextPath}/'+url+'" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',        closable:true   }); }  } </script> <%SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");String date= format.format(new Date());  %>  </head>    <body>   <body class="easyui-layout">       <div data-options="region:'north',noheader:true" style="height:120px;background:#3B7194; padding-top: 38px; overflow:hidden;">    <div>     <span style="font-size: 30px;font-weight: bolder;color: white;font-family: 微软雅黑;margin-left: 30px;"><img src="script/Imgs/logo.ico" style="width: 50px" name="旗鱼科技">客户关系管理系统</span>    </div>    <div>      <span style="float:right; color: white;font-family: 微软雅黑; margin-bottom:0px; padding-right:10px; font-size: 12px;">     <marquee direction="left" loop="-1" width="400" height="300" behavior="scroll" scrollamount="5">欢迎  ${user.userName}登录CRM管理系统!当前是<%=date%></marquee>    <a href="login.jsp" class="easyui-linkbutton"> 退出登录</a></span>    </div>    </div>    <div data-options="region:'south',noheader:true" style="height:40px;background:#3B7194;">    <span style="float: right;padding-top: 10px;color: white;font-family: 微软雅黑; padding-right:500px; font-size: 12px;overflow:hidden;">©2016  版权归个人所有 翻版必究  CREATE BY LauKei</span>    </div>      <div data-options="region:'west',title:'导航菜单',split:true,iconCls:'icon-daohang'" style="width:160px;">    <ul id="treemenu">    </ul>    </div>       <div data-options="region:'center',noheader:true,split:true">    <div class="easyui-tabs" style="fit:true; border: false" id="tabs">      <div title="首页">             <div><span><img src="script/Imgs/welcome.jpg" style="width: 100%; height: 100%;"/></span>              </div>      </div>    </div>   </div>   </body> </html>


login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>CRM客戶管理系統  Customer Relationship Management System</title>    <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link rel="stylesheet" href="script/css/style.css" tppabs="script/css/style.css" /></link><script src="script/js/jquery.js"></script><script src="script/js/verificationNumbers.js" tppabs="script/js/verificationNumbers.js"></script><script src="script/js/Particleground.js" tppabs="script/js/Particleground.js"></script><style type="text/css">body{height:100%;background:#3b7194;overflow:hidden;}canvas{z-index:-1;position:absolute;}</style><script>$(document).ready(function() {  //粒子背景特效  $('body').particleground({    dotColor: '#5cbdaa',    lineColor: '#5cbdaa'  });  //验证码  createCode();  $(".submit_btn").click(function(){  $.post("userAction!login",{"user.userName":$("#uname").val(),"user.userPassword":$("#upass").val()},function(data){  if (data!=null) {window.location="index.jsp";}else{$messager.show({title:'登录提示',msg:'用户名或者密码有误。',timeout:3000,showType:'slide'});}  },"json");  });  });</script></head><body><dl class="admin_login"> <dt>  <strong>CRM客户管理系统</strong>  <em>Customer Relationship Management System</em> </dt> <dd class="user_icon">  <input id="uname" type="text" placeholder="账号" class="login_txtbx"/> </dd> <dd class="pwd_icon">  <input id="upass" type="password" placeholder="密码" class="login_txtbx"/> </dd> <dd class="val_icon">  <div class="checkcode">    <input type="text" id="J_codetext" placeholder="验证码" maxlength="4" class="login_txtbx">    <canvas class="J_codeimg" id="myCanvas" onclick="createCode()">对不起,您的浏览器不支持,请下载最新版浏览器!</canvas>  </div>  <input type="button" value="换一张" class="ver_btn" onClick="validate();">  </dd> <dd>  <input type="button" value="立即登陆" class="submit_btn"/> </dd> <dd><p>©2016  版权归个人所有 翻版必究 </p><p>CREATE BY LauKei</p> </dd></dl></body></html>



本代码是自己第一次写的,有什么问题请指出!未经允许禁止转载。















0 0
原创粉丝点击