SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)

后台搭建-前端展示

      • 1:加入maven項目
          • 1.1创建如图中的工作流程包+配置文件
          • 1.2导入Spring容器框架(业务逻辑处理)
      • 2.Base(接口工具类):
      • 3.SYS模块包:
        • **Util工具类源码**
        • **Model实体类**
        • **Mapping包**
        • Dao层
        • Service
        • Bas項目包:
      • 4.前端Vue+Element-UI源代码:

1:加入maven項目

1.1创建如图中的工作流程包+配置文件

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第1张图片

1.2导入Spring容器框架(业务逻辑处理)

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第2张图片
pom.xml----》动态下载Spring+Struts2所需要的依赖

	
	  4.0.0
	  com.zking
	  vueSPA
	  war
	  0.0.1-SNAPSHOT
	  vueSPA Maven Webapp
	  http://maven.apache.org
		
			5.2.12.Final
			5.1.44
			5.0.1.RELEASE
			2.5.13
			1.7.7
			2.9.1
			3.2.0
			4.12
			4.0.1
			1.2
			1.1.2
			8.5.20
			2.9.3
		
		
			
			
				org.hibernate
				hibernate-core
				${hibernate.version}
			
			
				org.hibernate
				hibernate-c3p0
				${hibernate.version}
			
			
				org.hibernate
				hibernate-ehcache
				${hibernate.version}
			
			
				mysql
				mysql-connector-java
				${mysql.driver.version}
			
			
			
				org.springframework
				spring-context
				${spring.version}
			
			
				org.springframework
				spring-orm
				${spring.version}
			
			
				org.springframework
				spring-web
				${spring.version}
			
	
			
			
				org.springframework
				spring-aop
				${spring.version}
			
	
			
				org.springframework
				spring-aspects
				${spring.version}
			
	
			
				org.aspectj
				aspectjrt
				1.7.2
			
			
				org.aspectj
				aspectjweaver
				1.7.2
			
			
				cglib
				cglib
				2.1_3
			
			
			
			
				org.apache.struts
				struts2-core
				${struts2.version}
				
					
						commons-io
						commons-io
					
					
						log4j-api
						org.apache.logging.log4j
					
				
			
			
				org.apache.struts
				struts2-spring-plugin
				${struts2.version}
				
					
						spring-web
						org.springframework
					
					
						spring-beans
						org.springframework
					
					
						spring-context
						org.springframework
					
					
						spring-core
						org.springframework
					
				
			
	
			
			
			
				org.slf4j
				slf4j-api
				${slf4j.version}
			
			
				org.slf4j
				jcl-over-slf4j
				${slf4j.version}
				runtime
			
	
			
			
				org.apache.logging.log4j
				log4j-slf4j-impl
				${log4j.version}
				
					
						slf4j-api
						org.slf4j
					
				
			
	
			
			
				org.apache.logging.log4j
				log4j-api
				${log4j.version}
			
			
				org.apache.logging.log4j
				log4j-core
				${log4j.version}
			
	
			
			
				org.apache.logging.log4j
				log4j-web
				${log4j.version}
				runtime
			
			
			
				com.lmax
				disruptor
				${disruptor.version}
			
	
			
			
				junit
				junit
				${junit.version}
				test
			
			
				javax.servlet
				javax.servlet-api
				${servlet.version}
				provided
			
	
			
			
				javax.servlet.jsp.jstl
				jstl
				${jstl.version}
			
			
				taglibs
				standard
				${standard.version}
			
	
			
			
				org.apache.tomcat
				tomcat-jsp-api
				${tomcat-jsp-api.version}
				provided
			
			
			
				com.fasterxml.jackson.core
				jackson-databind
				${jackson.version}
				
					
						jackson-annotations
						com.fasterxml.jackson.core
					
				
			
			
				com.fasterxml.jackson.core
				jackson-core
				${jackson.version}
			
			
				com.fasterxml.jackson.core
				jackson-annotations
				${jackson.version}
			
		
	  
	    vueSPA
	    
				
					org.apache.maven.plugins
					maven-compiler-plugin
					3.7.0
					
						1.8
						1.8
						UTF-8
					
				
			
	  
	

web.xml源码:(会报错因为Util工具类还没有进入进来

	
	  Archetype Created Web Application
	  
		
			contextConfigLocation
			classpath:spring.xml
		
		
			org.springframework.web.context.ContextLoaderListener
		
		
		
	
		
		
			
				org.springframework.web.util.IntrospectorCleanupListener
			
		
		
		
		
			CorsFilter
			com.zking.login.sys.util.CorsFilter
		
		
			CorsFilter
			/*
		
		
	
		
		
			EncodingFiter
			com.zking.login.sys.util.EncodingFiter
		
		
			EncodingFiter
			/*
		
	
		
		
			OpenSessionInView
			
				org.springframework.orm.hibernate5.support.OpenSessionInViewFilter
			
		
		
			OpenSessionInView
			/*
		
	
		
		
			struts2
			org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
		
		
			struts2
			/*
		
	

1.3Spring+Struts2配置文件源码:
Spring.xml:



	
	
	

Spring-sys.xml:

	
	
			
		
		
		
		
		
		
		
		
		
		
		
		
			
				
			
		
		
		
			
				
			
		
		
		
		
		 
			
				
			
		
		
		
			
				
			
		 
	

Spring-base.xml c3p0连接池:



		
	
	
		
		
		
		

		
		

		
		

		
		

		
		

		
		

		
		

		
		

		
		

		
		

		
		
	

	
	
		
		
			
		
		
		
			
				org.hibernate.dialect.MySQLDialect
				true
				true
				true
				true
				org.hibernate.cache.ehcache.EhCacheRegionFactory
				
				true
			
		
		
		
			
				mapping/LoginUser.hbm.xml
				mapping/TreeNode.hbm.xml
				mapping/DictModel.hbm.xml
			
		
	

	
	
		
			
		
	

	
	
	

	
	
		
	

	
	
	
		
			
			
			
			
			
			
		
	

	
	
	
		
		
		
		
		
		
		
	
	
	
	
	
		
			
		
	

Spring-bas.xml数据类型:



		
	
	
	
	
	
	
	
	
		
			
		
	
	
	
	
	 
		
			
		
	

Struts.xml:

	
	
	
		
		
		
	

Struts-sys.xml




	
		
		
		
		
	

Struts-base.xml:

	
	
	
		
		
		
		
		
		
		 
		
			regex:.*
		 
	

Struts-bas.xml:




	
		
		
	

log4j2.xml源码:





	
		
		/root/workspace/lucenedemo/logs
		/root/workspace/lucenedemo/logs/error
		/root/workspace/lucenedemo/logs/warn
		%d{yyyy-MM-dd HH:mm:ss.SSS} [%t-%L] %-5level %logger{36} - %msg%n
	

	
		
		
			
			
			
			
			
		

		
		
		
			
		
		
		
			
			
			
			
				
				
				
				
				
				
			
		

		
			
			
			
				
				
			
			
			
		

		
			
			
			
				
				
				
			
		

	

	
	
		
		
		

		
		
		
		
		
		


		
		
			
			
			
			
		

	


2.Base(接口工具类):

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第3张图片
BaseAction源码:

package com.zking.login.base.action;

import java.io.IOException;
import java.io.Serializable;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.stereotype.Controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.opensymphony.xwork2.ActionSupport;
public abstract class BaseAction extends ActionSupport implements Serializable, ServletRequestAware, ServletResponseAware {

	private static final long serialVersionUID = -2182475216409413582L;
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	protected ServletContext application;
	
	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response=response;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
		this.session=request.getSession();
		this.application=request.getServletContext();
	}
	
	public void writeJson(Object data) {
		ObjectMapper mapper = new ObjectMapper();
		try {
			mapper.writeValue(this.response.getOutputStream(), data);
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

}

BaseDao源码:

package com.zking.login.base.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import com.zking.login.base.util.PageBean;


public class BaseDao extends HibernateDaoSupport implements Serializable {

	private static final long serialVersionUID = 1619854797335382396L;

	private Logger log = LogManager.getLogger(BaseDao.class);

	public BaseDao() {
		super();
	}

	/**
	 * 通用赋值方法
	 * 
	 * @param query
	 * @param args
	 */
	@SuppressWarnings({ "unused", "rawtypes" })
	private void setParameters(Query query, Map args) {
		if (null == args || 0 == args.size()) {
			return;
		}
		log.info("hql查询参数为:" + args);

		String name = null;
		Object value = null;
		for (Map.Entry entry : args.entrySet()) {
			name = entry.getKey();// min,uname
			value = entry.getValue();// 1000f,'z%'
			// query.setFloat(name, value);
			// query.setString(name, value);
			// query.setParameter(param, value);//8+1
			if (value instanceof Collection) {// List和Set
				query.setParameterList(name, (Collection) value);
			} else if (value instanceof Object[]) {
				query.setParameterList(name, (Object[]) value);
			} else {
				query.setParameter(name, value);
			}
		}
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List executeQuery(final String hql, final Map args, final PageBean pageBean) {
		// Session session =
		// this.getHibernateTemplate().getSessionFactory().openSession();

		return (List) this.getHibernateTemplate().execute(new HibernateCallback() {
			@Override
			public Object doInHibernate(Session session) throws HibernateException {
				// 1. 查满足条件的总记录数
				Query query = null;
				if (null != pageBean && pageBean.isPagination()) {
					String countHql = getCountHql(hql);
					log.info("countHql[" + countHql + "]");
					query = session.createQuery(countHql);
					setParameters(query, args);// 给占位符赋值
					Object total = query.uniqueResult();
					pageBean.setTotal(total.toString());
				}
				// 2. 查满足条件并指定页码 的记录
				log.info("countHql[" + hql + "]");
				query = session.createQuery(hql);
				if (null != pageBean && pageBean.isPagination()) {
					query.setFirstResult(pageBean.getStartIndex());
					query.setMaxResults(pageBean.getRows());
				}
				setParameters(query, args);// 给占位符赋值
				List list = query.list();
				return list;
			}
		});
	}
	// from Account a where 1=1 OrDer by a.balance desc
	// from Account a where 1=1
	// select a.userName from Account a where 1=1 OrDer by a.balance desc
	// select count(*) from Account a where 1=1

	/**
	 * 将普通的hql转换成查总记录数的hql
	 * 
	 * @param hql
	 * @return
	 */
	private static String getCountHql(String hql) {
		String newHql = new String(hql).toUpperCase();
		int start = newHql.indexOf("FROM ");
		int end = newHql.indexOf("ORDER BY");
		if (-1 == end) {
			newHql = "select count(*) " + hql.substring(start);
		} else {
			newHql = "select count(*) " + hql.substring(start, end);
		}
		return newHql;
	}

	// public static void main(String[] args) {
	// String hql2 = "from Order o where o.orderId in (1,2,3,5)";// (:orderIds)
	// String hql = "select a.userName from Account a where 1=1 and a.balance >=
	// :min order by a.balance";
	// System.out.println(getCountHql(hql));
	// }
}

BaseModel源码:

package com.zking.login.base.model;

import java.io.Serializable;

public abstract class BaseModel implements Serializable{
	private static final long serialVersionUID = 8624999326463657703L;

}

BaseService 源码:

package com.zking.login.base.service;

import java.io.Serializable;

public abstract class BaseService implements Serializable{

	private static final long serialVersionUID = 1L;

}

PageBean 源码:

package com.zking.login.base.util;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

public class PageBean {

	private int page = 1;// 页码
	private int rows = 10;// 行数/页大小
	private int total = 0;// 总记录数

	private boolean pagination = true;// 默认分页

	private String url;// 上一次请求的地址
	private Map parameterMap;// 上一次请求的所有参数

	public PageBean() {
		super();
	}

	/**
	 * 对分页bean进行初始化
	 * 
	 * @param request
	 */
	public void setRequest(HttpServletRequest request) {
		// 公共参数
		this.setPage(request.getParameter("page"));
		this.setRows(request.getParameter("rows"));
		this.setPagination(request.getParameter("pagination"));

		// 请求地址和请求参数
		this.setUrl(request.getContextPath() + request.getServletPath());
		this.setParameterMap(request.getParameterMap());
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map getParameterMap() {
		return parameterMap;
	}

	public void setParameterMap(Map parameterMap) {
		this.parameterMap = parameterMap;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public void setPage(String page) {
		if (null != page && !"".equals(page.trim())) {
			this.page = Integer.parseInt(page);
		}
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public void setRows(String rows) {
		if (null != rows && !"".equals(rows.trim())) {
			this.rows = Integer.parseInt(rows);
		}
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public void setTotal(String total) {
		this.total = Integer.parseInt(total);
	}

	public boolean isPagination() {
		return pagination;
	}

	public void setPagination(boolean pagination) {
		this.pagination = pagination;
	}

	public void setPagination(String pagination) {
		if ("false".equals(pagination)) {
			this.pagination = false;
		}
	}

	/**
	 * 下一页
	 * 
	 * @return
	 */
	public int getNextPage() {
		int nextPage = page + 1;
		if (nextPage > this.getMaxPage()) {
			nextPage = this.getMaxPage();
		}
		return nextPage;
	}

	/**
	 * 上一页
	 * 
	 * @return
	 */
	public int getPreviousPage() {
		int previousPage = page - 1;
		if (previousPage < 1) {
			previousPage = 1;
		}
		return previousPage;
	}

	/**
	 * 最大页码
	 * 
	 * @return
	 */
	public int getMaxPage() {
		return total % rows == 0 ? total / rows : total / rows + 1;
	}

	/**
	 * 起始记录的下标
	 * 
	 * @return
	 */
	public int getStartIndex() {
		return (page - 1) * rows;
	}

	@Override
	public String toString() {
		return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination + "]";
	}

}

3.SYS模块包:

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第4张图片

Util工具类源码

CorsFilter(配置tomcat允许跨域访问):

	package com.zking.login.sys.util;
	
	import java.io.IOException;
	
	import javax.servlet.Filter;
	import javax.servlet.FilterChain;
	import javax.servlet.FilterConfig;
	import javax.servlet.ServletException;
	import javax.servlet.ServletRequest;
	import javax.servlet.ServletResponse;
	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpServletResponse;
	
	/**
	 * 配置tomcat允许跨域访问
	 * 
	 * @author Administrator
	 *
	 */
	public class CorsFilter implements Filter {
	
		@Override
		public void init(FilterConfig filterConfig) throws ServletException {
		}
	
		// @Override
		// public void doFilter(ServletRequest servletRequest, ServletResponse
		// servletResponse, FilterChain filterChain)
		// throws IOException, ServletException {
		// HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
		//
		// // Access-Control-Allow-Origin就是我们需要设置的域名
		// // Access-Control-Allow-Headers跨域允许包含的头。
		// // Access-Control-Allow-Methods是允许的请求方式
		// httpResponse.addHeader("Access-Control-Allow-Origin", "*");// *,任何域名
		// httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT,
		// DELETE");
		// // httpResponse.setHeader("Access-Control-Allow-Headers", "Origin,
		// // X-Requested-With, Content-Type, Accept");
		//
		// // 允许请求头Token
		// httpResponse.setHeader("Access-Control-Allow-Headers",
		// "Origin,X-Requested-With, Content-Type, Accept, Token");
		// HttpServletRequest req = (HttpServletRequest) servletRequest;
		// System.out.println("Token=" + req.getHeader("Token"));
		// if("OPTIONS".equals(req.getMethod())) {
		// return;
		// }
		//
		//
		// filterChain.doFilter(servletRequest, servletResponse);
		// }
	
		@Override
		public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
				throws IOException, ServletException {
			HttpServletResponse resp = (HttpServletResponse) servletResponse;
			HttpServletRequest req = (HttpServletRequest) servletRequest;
	
			// Access-Control-Allow-Origin就是我们需要设置的域名
			// Access-Control-Allow-Headers跨域允许包含的头。
			// Access-Control-Allow-Methods是允许的请求方式
			resp.setHeader("Access-Control-Allow-Origin", "*");// *,任何域名
			resp.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE");
			resp.setHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With, Content-Type, Accept");
	
			// 允许请求头Token
			// httpResponse.setHeader("Access-Control-Allow-Headers","Origin,X-Requested-With,
			// Content-Type, Accept, Token");
			// System.out.println("Token=" + req.getHeader("Token"));
	
			if ("OPTIONS".equals(req.getMethod())) {// axios的ajax会发两次请求,第一次提交方式为:option,直接返回即可
				return;
			}
			filterChain.doFilter(servletRequest, servletResponse);
		}
	
		@Override
		public void destroy() {
	
		}
	}

EncodingFiter(中文乱码处理器):

package com.zking.login.sys.util;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 中文乱码处理
 * 
 */
public class EncodingFiter implements Filter {

	private String encoding = "UTF-8";// 默认字符集

	public EncodingFiter() {
		super();
	}

	public void destroy() {
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse res = (HttpServletResponse) response;

		// 中文处理必须放到 chain.doFilter(request, response)方法前面
		res.setContentType("text/html;charset=" + this.encoding);
		if (req.getMethod().equalsIgnoreCase("post")) {
			req.setCharacterEncoding(this.encoding);
		} else {
			Map map = req.getParameterMap();// 保存所有参数名=参数值(数组)的Map集合
			Set set = map.keySet();// 取出所有参数名
			Iterator it = set.iterator();
			while (it.hasNext()) {
				String name = (String) it.next();
				String[] values = (String[]) map.get(name);// 取出参数值[注:参数值为一个数组]
				for (int i = 0; i < values.length; i++) {
					values[i] = new String(values[i].getBytes("ISO-8859-1"),
							this.encoding);
				}
			}
		}

		chain.doFilter(request, response);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		String s = filterConfig.getInitParameter("encoding");// 读取web.xml文件中配置的字符集
		if (null != s && !s.trim().equals("")) {
			this.encoding = s.trim();
		}
	}

}

JsonData(服务器返回给客户端的JSON格式的数据):

package com.zking.login.sys.util;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 服务器返回给客户端的JSON格式的数据
 *
 */
public class JsonData extends HashMap implements Serializable {

	private static final long serialVersionUID = -8855960778711040221L;

	private static final String CODE_KEY = "code";// 操作代码 0 成功 非0 失败
	private static final String MESSAGE_KEY = "message";// 操作消息
	private static final String RESULT_KEY = "result";// 结果集
	private static final String PAGE_KEY = "page";// 页码
	private static final String ROWS_KEY = "rows";// 每页行数/页大小
	private static final String TOTAL_KEY = "total";// 总记录数

	public JsonData() {
		super();
		this.put(CODE_KEY, 0);// 默认操作成功
	}

	public void setCode(Integer code) {
		this.put(CODE_KEY, code);
	}

	public void setMessage(String message) {
		this.put(MESSAGE_KEY, message);
	}

	public void setResult(Object result) {
		this.put(RESULT_KEY, result);
	}

	public void setPage(Integer page) {
		this.put(PAGE_KEY, page);
	}

	public void setRows(Integer rows) {
		this.put(ROWS_KEY, rows);
	}

	public void setTotal(Integer total) {
		this.put(TOTAL_KEY, total);
	}

}

PageBean(分页工具类):

	package com.zking.login.sys.util;
	
	import java.util.Map;
	
	import javax.servlet.http.HttpServletRequest;
	
	public class PageBean {
	
		private int page = 1;// 页码
		private int rows = 10;// 行数/页大小
		private int total = 0;// 总记录数
	
		private boolean pagination = true;// 默认分页
	
		private String url;// 上一次请求的地址
		private Map parameterMap;// 上一次请求的所有参数
	
		public PageBean() {
			super();
		}
	
		/**
		 * 对分页bean进行初始化
		 * 
		 * @param request
		 */
		public void setRequest(HttpServletRequest request) {
			// 公共参数
			this.setPage(request.getParameter("page"));
			this.setRows(request.getParameter("rows"));
			this.setPagination(request.getParameter("pagination"));
	
			// 请求地址和请求参数
			this.setUrl(request.getContextPath() + request.getServletPath());
			this.setParameterMap(request.getParameterMap());
		}
	
		public String getUrl() {
			return url;
		}
	
		public void setUrl(String url) {
			this.url = url;
		}
	
		public Map getParameterMap() {
			return parameterMap;
		}
	
		public void setParameterMap(Map parameterMap) {
			this.parameterMap = parameterMap;
		}
	
		public int getPage() {
			return page;
		}
	
		public void setPage(int page) {
			this.page = page;
		}
	
		public void setPage(String page) {
			if (null != page && !"".equals(page.trim())) {
				this.page = Integer.parseInt(page);
			}
		}
	
		public int getRows() {
			return rows;
		}
	
		public void setRows(int rows) {
			this.rows = rows;
		}
	
		public void setRows(String rows) {
			if (null != rows && !"".equals(rows.trim())) {
				this.rows = Integer.parseInt(rows);
			}
		}
	
		public int getTotal() {
			return total;
		}
	
		public void setTotal(int total) {
			this.total = total;
		}
	
		public void setTotal(String total) {
			this.total = Integer.parseInt(total);
		}
	
		public boolean isPagination() {
			return pagination;
		}
	
		public void setPagination(boolean pagination) {
			this.pagination = pagination;
		}
	
		public void setPagination(String pagination) {
			if ("false".equals(pagination)) {
				this.pagination = false;
			}
		}
	
		/**
		 * 下一页
		 * 
		 * @return
		 */
		public int getNextPage() {
			int nextPage = page + 1;
			if (nextPage > this.getMaxPage()) {
				nextPage = this.getMaxPage();
			}
			return nextPage;
		}
	
		/**
		 * 上一页
		 * 
		 * @return
		 */
		public int getPreviousPage() {
			int previousPage = page - 1;
			if (previousPage < 1) {
				previousPage = 1;
			}
			return previousPage;
		}
	
		/**
		 * 最大页码
		 * 
		 * @return
		 */
		public int getMaxPage() {
			return total % rows == 0 ? total / rows : total / rows + 1;
		}
	
		/**
		 * 起始记录的下标
		 * 
		 * @return
		 */
		public int getStartIndex() {
			return (page - 1) * rows;
		}
	
		@Override
		public String toString() {
			return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination + "]";
		}
	
	}

StringUtils(私有的构造方法,保护此类不能在外部实例化):

	package com.zking.login.sys.util;
	
	public class StringUtils {
		// 私有的构造方法,保护此类不能在外部实例化
		private StringUtils() {
		}
	
		/**
		 * 如果字符串等于null或去空格后等于"",则返回true,否则返回false
		 * 
		 * @param s
		 * @return
		 */
		public static boolean isBlank(String s) {
			boolean b = false;
			if (null == s || s.trim().equals("")) {
				b = true;
			}
			return b;
		}
		
		/**
		 * 如果字符串不等于null或去空格后不等于"",则返回true,否则返回false
		 * 
		 * @param s
		 * @return
		 */
		public static boolean isNotBlank(String s) {
			return !isBlank(s);
		}
	
	}

Model实体类

LoginUser (实体类):

package com.zking.login.sys.model;

import java.io.Serializable;
import java.sql.Timestamp;

import com.zking.login.base.model.BaseModel;

public class LoginUser extends BaseModel {
	
	private Long userid;
	private String username;
	private String password;
	
	private String salt;
	private Integer locked;
	private Timestamp createDatetime;
	
	public LoginUser() {
	}

	public Long getUserid() {
		return userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Integer getLocked() {
		return locked;
	}

	public void setLocked(Integer locked) {
		this.locked = locked;
	}

	public Timestamp getCreateDatetime() {
		return createDatetime;
	}

	public void setCreateDatetime(Timestamp createDatetime) {
		this.createDatetime = createDatetime;
	}

	@Override
	public String toString() {
		return "LoginUser [userid=" + userid + ", username=" + username + ", password=" + password + ", salt=" + salt
				+ ", locked=" + locked + ", createDatetime=" + createDatetime + "]";
	}
}

Mapping包

LoginUser.hbm.xml(实体映射文件)




	
		
			
		
		
		
		
		
		
	

Dao层

IUserDao :

package com.zking.login.sys.dao;

import java.util.List;

import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.util.PageBean;

public interface IUserDao {
	
	/**
	 * 注册
	 */
//	void add(LoginUser loginUser);
	
	/**
	 * 删除用户
	 */
//	void del(LoginUser loginUser);
	
	/**
	 * 修改用户
	 */
//	void upde(String loanaem,String loapwd,LoginUser loginUser);
	
	/**
	 * 登陆
	 */
	LoginUser load(LoginUser loginUser);
	
	
	/**
	 * 查询所有用户
	 */
	//List list(LoginUser loginUser,PageBean pagebean);

}

UserDaoimpl :

	package com.zking.login.sys.dao.impl;
	
	import java.util.HashMap;
	import java.util.Map;
	
	import org.hibernate.HibernateException;
	import org.hibernate.Session;
	import org.hibernate.query.Query;
	import org.springframework.orm.hibernate5.HibernateCallback;
	
	import com.zking.login.base.dao.BaseDao;
	import com.zking.login.sys.dao.IUserDao;
	import com.zking.login.sys.model.LoginUser;
	
	public class UserDaoimpl extends BaseDao implements IUserDao {
	
		@Override
		public LoginUser load(LoginUser user) {
			return this.getHibernateTemplate().execute(new HibernateCallback() {
				@Override
				public LoginUser doInHibernate(Session session) throws HibernateException {
					Query query = session.createQuery("from LoginUser u where u.username = :username");//查询出结果放进json中
					query.setString("username", user.getUsername());//把json转为string类型
					LoginUser u = (LoginUser) query.uniqueResult();//query内部一个方法
					return u;
				}
			});
		}
	
	}

Service

IUserService(登陆):

package com.zking.login.sys.service;

import java.util.List;

import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.util.PageBean;

public interface IUserService {
	

	/**
	 * 登陆
	 */
	LoginUser load(LoginUser loginUser);
	
	
	/**
	 * 查询所有用户
	 */
//	List list(LoginUser loginUser,PageBean pagebean);

}

UserService(登陆):

package com.zking.login.sys.service.impl;

import java.util.List;

import com.zking.login.base.service.BaseService;
import com.zking.login.sys.dao.IUserDao;
import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.service.IUserService;
import com.zking.login.sys.util.PageBean;

public class UserService extends BaseService  implements IUserService{
	
	private IUserDao userdao;
	
	public UserService() {
	}
	public IUserDao getUserdao() {
		return userdao;
	}

	public void setUserdao(IUserDao userdao) {
		this.userdao = userdao;
	}


	@Override
	public LoginUser load(LoginUser loginUser) {
		return userdao.load(loginUser);
	}


}

UserAction:

package com.zking.login.sys.action;

import com.opensymphony.xwork2.ModelDriven;
import com.zking.login.base.action.BaseAction;
import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.service.IUserService;
import com.zking.login.sys.util.JsonData;

public class UserAction extends BaseAction implements ModelDriven{
	
	private static final long serialVersionUID = 1L;

	private IUserService userService;
	
	private LoginUser user = new LoginUser();
	
	public UserAction() {
		
	}
	public IUserService getUserService() {
		return userService;
	}
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	@Override
	public LoginUser getModel() {
		return user;
	}
	
	public String execute() {
		System.out.println(request.getMethod());
		System.out.println("后台Action"+this.user);
		JsonData jsonData = new JsonData();
		
		LoginUser u = userService.load(user);
		if(u != null && u.getPassword().equals(user.getPassword())) {
			jsonData.setCode(0);
			jsonData.setMessage("登陆成功");
		}else {
			jsonData.setCode(-1);
			jsonData.setMessage("账号或密码错误");
		}
		this.writeJson(jsonData);
		return null;
	}
	

}

SYS项目模块+动态树:
SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第5张图片
TreeNode 源码:

package com.zking.login.sys.model;

import java.util.ArrayList;
import java.util.List;

import com.zking.login.base.model.BaseModel;

public class TreeNode extends BaseModel {
	
	private static final long serialVersionUID = 1L;
	
	private Integer treeNodeId;
	private String treeNodeName;
	private Integer treeNodeType;
	
	private Integer parentNodeId;
	private String url;
	private Integer position;
	
	private String icon;
	private List children = new ArrayList();
	
	
	public TreeNode() {
	}


	public Integer getTreeNodeId() {
		return treeNodeId;
	}


	public void setTreeNodeId(Integer treeNodeId) {
		this.treeNodeId = treeNodeId;
	}


	public String getTreeNodeName() {
		return treeNodeName;
	}


	public void setTreeNodeName(String treeNodeName) {
		this.treeNodeName = treeNodeName;
	}


	public Integer getTreeNodeType() {
		return treeNodeType;
	}


	public void setTreeNodeType(Integer treeNodeType) {
		this.treeNodeType = treeNodeType;
	}


	public Integer getParentNodeId() {
		return parentNodeId;
	}


	public void setParentNodeId(Integer parentNodeId) {
		this.parentNodeId = parentNodeId;
	}


	public String getUrl() {
		return url;
	}


	public void setUrl(String url) {
		this.url = url;
	}


	public Integer getPosition() {
		return position;
	}


	public void setPosition(Integer position) {
		this.position = position;
	}


	public String getIcon() {
		return icon;
	}


	public void setIcon(String icon) {
		this.icon = icon;
	}


	public List getChildren() {
		return children;
	}


	public void setChildren(List children) {
		this.children = children;
	}


	@Override
	public String toString() {
		return "TreeNode [treeNodeId=" + treeNodeId + ", treeNodeName=" + treeNodeName + ", treeNodeType="
				+ treeNodeType + ", parentNodeId=" + parentNodeId + ", url=" + url + ", position=" + position
				+ ", icon=" + icon + ", children=" + children + "]";
	}
}

LoginUser.hbm.xml(实体映射文件):




	
		
			
		
		
		
		
		
		
	

ITreeNodeDao :

package com.zking.login.sys.dao;

import java.util.List;

import com.zking.login.sys.model.TreeNode;

public interface ITreeNodeDao {
	
	/**
	 * 查询所有一级节点
	 * @return
	 */
	 List listBoots();

}

TreeNodeDAOimpl :

package com.zking.login.sys.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zking.login.base.dao.BaseDao;
import com.zking.login.sys.dao.ITreeNodeDao;
import com.zking.login.sys.dao.IUserDao;
import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.model.TreeNode;

public class TreeNodeDAOimpl extends BaseDao implements ITreeNodeDao {

	
	/**
	 * 查询一级父节点
	 */
	@Override
	public List listBoots() {
			String hql="from TreeNode u where u.parentNodeId is null";
			
			List list = this.executeQuery(hql, null, null);
			for (TreeNode n : list) {
				this.initchildren(n);
			}
			
			return list;
	}
	
	//递归方法
	/**
	 * 自己算自己是否有子节点
	 * @param treeNode
	 */
	public void initchildren(TreeNode treeNode) {
		String hql = "from TreeNode u where u.parentNodeId = :pid ";
		Map  args = new HashMap();
		args.put("pid", treeNode.getTreeNodeId());
		
		List children = this.executeQuery(hql, args, null);
		treeNode.setChildren(children);
		
		for(TreeNode n : children) {
			this.initchildren(n);
		}
		
	}

}

ITreeNodeService 源码:

package com.zking.login.sys.service;

import java.util.List;

import com.zking.login.sys.dao.ITreeNodeDao;
import com.zking.login.sys.model.TreeNode;

public interface ITreeNodeService {
	
	/**
	 * 查询所有的一级节点,但是会递归算法查找父节点子节点
	 * @return
	 */
	List listRoots();
	

}

TreeNodeServiceimpl 源码:

package com.zking.login.sys.service.impl;

import java.util.List;

import com.zking.login.base.service.BaseService;
import com.zking.login.sys.dao.ITreeNodeDao;
import com.zking.login.sys.model.TreeNode;
import com.zking.login.sys.service.ITreeNodeService;

public class TreeNodeServiceimpl extends BaseService implements ITreeNodeService {

	private static final long serialVersionUID = 1L;
	
	private ITreeNodeDao treenodedao;
	
	public TreeNodeServiceimpl() {
	}
	public ITreeNodeDao getTreenodedao() {
		return treenodedao;
	}
	public void setTreenodedao(ITreeNodeDao treenodedao) {
		this.treenodedao = treenodedao;
	}
	@Override
	public List listRoots() {
		return treenodedao.listBoots();
	}

	

}

TreeNodeAction 源码:

package com.zking.login.sys.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ModelDriven;
import com.zking.login.base.action.BaseAction;
import com.zking.login.sys.model.TreeNode;
import com.zking.login.sys.service.ITreeNodeService;
import com.zking.login.sys.util.JsonData;

public class TreeNodeAction extends BaseAction{
	
	private static final long serialVersionUID = 1L;

	ITreeNodeService treenodeService;
	
	public TreeNodeAction() {
		
	}
	public ITreeNodeService getTreenodeService() {
		return treenodeService;
	}
	public void setTreenodeService(ITreeNodeService treenodeService) {
		this.treenodeService = treenodeService;
	}


	public String Boots() {
		JsonData jsonData = new JsonData();
		
		List list = treenodeService.listRoots();
		
		jsonData.setCode(0);
		jsonData.setMessage("菜单查询成功");
		jsonData.setResult(list);
		
		this.writeJson(jsonData);
		return null;
	}
	

}

Bas項目包:

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第6张图片
DictModel源码:

package com.zking.login.bas.model;

import com.zking.login.base.model.BaseModel;

public class DictModel extends BaseModel  {

	private static final long serialVersionUID = 1L;
	
	private Long dictId;
	private String dictType;
	private String dictItem;
	
	private String dictValue;
	private Integer dictIsEditable;
	
	public DictModel() {
	}

	public Long getDictId() {
		return dictId;
	}

	public void setDictId(Long dictId) {
		this.dictId = dictId;
	}

	public String getDictType() {
		return dictType;
	}

	public void setDictType(String dictType) {
		this.dictType = dictType;
	}

	public String getDictItem() {
		return dictItem;
	}

	public void setDictItem(String dictItem) {
		this.dictItem = dictItem;
	}

	public String getDictValue() {
		return dictValue;
	}

	public void setDictValue(String dictValue) {
		this.dictValue = dictValue;
	}

	public Integer getDictIsEditable() {
		return dictIsEditable;
	}

	public void setDictIsEditable(Integer dictIsEditable) {
		this.dictIsEditable = dictIsEditable;
	}

	@Override
	public String toString() {
		return "DictModel [dictId=" + dictId + ", dictType=" + dictType + ", dictItem=" + dictItem + ", dictValue="
				+ dictValue + ", dictIsEditable=" + dictIsEditable + "]";
	}
}

DictModel.hbm.xml:




	
		
			
		
		
		
		
		
	

IDictDao源码 :

package com.zking.login.bas.dao;

import java.util.List;

import com.zking.login.bas.model.DictModel;
import com.zking.login.base.util.PageBean;

public interface IDictDao {
	
	void add(DictModel dictModel);//增加
	
	void edit(DictModel dictModel);//修改
	
	void delete(DictModel dictModel);//删除
	
	void editdictIsEditable(DictModel dictModel);//修改状态
	
	DictModel load(DictModel dictModel);//查询单个
	
	List listToDictType(DictModel dictModel);//根据类型查询单个
	
	List list(DictModel dictModel,PageBean pageBean);//查询所有+模糊查询+分页
	

}

DictDaoimpl 源码:

package com.zking.login.bas.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zking.login.bas.dao.IDictDao;
import com.zking.login.bas.model.DictModel;
import com.zking.login.base.dao.BaseDao;
import com.zking.login.base.util.PageBean;
import com.zking.login.sys.util.StringUtils;

import freemarker.template.utility.StringUtil;

public class DictDaoimpl extends BaseDao implements IDictDao {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 添加字典
	 * 
	 */
	@Override
	public void add(DictModel dictModel) {
		this.getHibernateTemplate().save(dictModel);
	}
	/**
	 * 修改书本信息
	 */
	@Override
	public void edit(DictModel dictModel) {
		DictModel d = load(dictModel);
		if(d!=null) {
			d.setDictType(dictModel.getDictType());
			d.setDictItem(dictModel.getDictItem());
			d.setDictValue(dictModel.getDictValue());
		}
	}

	
	/**
	 * 修改状态,1可操作,0不可操作
	 */
	@Override
	public void editdictIsEditable(DictModel dictModel) {
		DictModel d = load(dictModel);
		System.out.println(d);
		if(null != d) {
			if(new Integer(0).equals(d.getDictIsEditable())) {
				d.setDictIsEditable(1);
			}else {
				d.setDictIsEditable(0);
			}
		}
		
	}
	/**
	 * 根据id删除数据
	 */
	@Override
	public void delete(DictModel dictModel) {
		DictModel d =load(dictModel);
		if(null != d) {
			this.getHibernateTemplate().delete(d);
		}
	}
	
	/**
	 * 单条数据查询字典
	 */
	@Override
	public DictModel load(DictModel dictModel) {
		DictModel d = this.getHibernateTemplate().get(DictModel.class, dictModel.getDictId());
		return d;
	}
	
	/**
	 * 查询所有数据
	 */
	@Override
	public List listToDictType(DictModel dictModel) {
		String hql="from DictModel d where d.dictType = :dictType";
		
		Map args = new HashMap();
		args.put("dictType", dictModel.getDictType());
		
		return this.executeQuery(hql, args, null);
	}

	@Override
	public List list(DictModel dictModel,PageBean pageBean) {
		String hql="from DictModel d where 1=1";
		Map args = new HashMap();
		if(StringUtils.isNotBlank(dictModel.getDictType())) {
			hql+=" and d.dictType like :dictType";
			args.put("dictType", "%"+dictModel.getDictType().trim()+"%");
		}
		return this.executeQuery(hql, args, pageBean);
	}
}

IDictService 源码:

package com.zking.login.bas.service;

import java.util.List;

import com.zking.login.bas.model.DictModel;
import com.zking.login.base.util.PageBean;

public interface IDictService {
	
	void add(DictModel dictModel);//增加
	
	void edit(DictModel dictModel);//修改
	
	void delete(DictModel dictModel);//删除
	
	void editdictIsEditable(DictModel dictModel);//修改状态
	
	DictModel load(DictModel dictModel);//查询单个
	
	List listToDictType(DictModel dictModel);//根据类型查询单个
	
	List list(DictModel dictModel,PageBean pageBean);//查询所有+模糊查询+分页
}

DictServiceimpl 源码:

package com.zking.login.bas.service.impl;

import java.util.List;

import com.zking.login.bas.dao.IDictDao;
import com.zking.login.bas.model.DictModel;
import com.zking.login.bas.service.IDictService;
import com.zking.login.base.service.BaseService;
import com.zking.login.base.util.PageBean;

public class DictServiceimpl extends BaseService implements IDictService{
	
	private IDictDao dictDao;
	
	public DictServiceimpl() {
	}
	public IDictDao getDictdao() {
		return dictDao;
	}
	public void setDictdao(IDictDao dictdao) {
		this.dictDao = dictdao;
	}

	@Override
	public void add(DictModel dictModel) {
		this.dictDao.add(dictModel);
	}
	@Override
	public void edit(DictModel dictModel) {
		this.dictDao.edit(dictModel);
	}

	@Override
	public void delete(DictModel dictModel) {
		this.dictDao.delete(dictModel);
	}

	@Override
	public DictModel load(DictModel dictModel) {
		return this.dictDao.load(dictModel);
	}

	@Override
	public List listToDictType(DictModel dictModel) {
		return this.dictDao.listToDictType(dictModel);
	}

	@Override
	public List list(DictModel dictModel, PageBean pageBean) {
		return this.dictDao.list(dictModel, pageBean);
	}
	
	@Override
	public void editdictIsEditable(DictModel dictModel) {
		this.dictDao.editdictIsEditable(dictModel);
	}
}

DictAction 源码:

package com.zking.login.bas.action;

import java.util.List;

import com.opensymphony.xwork2.ModelDriven;
import com.zking.login.bas.model.DictModel;
import com.zking.login.bas.service.IDictService;
import com.zking.login.base.action.BaseAction;
import com.zking.login.base.util.PageBean;
import com.zking.login.sys.model.LoginUser;
import com.zking.login.sys.util.JsonData;

public class DictAction extends BaseAction implements ModelDriven{
	
	private static final long serialVersionUID = 1L;
	
	private IDictService dictService;
	private DictModel dictModel = new DictModel();
	
	@Override
	public DictModel getModel() {
		return dictModel;
	}
	
	public DictAction() {
	}
	public IDictService getDictService() {
		return dictService;
	}
	public void setDictService(IDictService dictService) {
		this.dictService = dictService;
	}
	public String list() {
		JsonData jsondata = new JsonData();
		PageBean pageBean = new PageBean();
		pageBean.setRequest(this.request);//把分页发送到前端
		List list = dictService.list(dictModel, pageBean);
		if(null!=list) {
			jsondata.setCode(0);
			jsondata.setMessage("查询成功");
			jsondata.setResult(list);
			
			//jsondata是以Map存储方式来存放值的(key,value)
			jsondata.put("page", pageBean.getPage());
			jsondata.put("rows", pageBean.getRows());
			jsondata.put("total", pageBean.getTotal());
		}
		this.writeJson(jsondata);
		return null;
		
	}
	
	public String editdictIsEditable() {
		dictService.editdictIsEditable(dictModel);
		JsonData jsondata = new JsonData();
		jsondata.setCode(0);
		jsondata.setMessage("字典状态改变成功");
		this.writeJson(jsondata);
		
		return null;
		
	}
	
	public String del() {
		dictService.delete(dictModel);
		JsonData jsondata = new JsonData();
			jsondata.setCode(0);
			jsondata.setMessage("删除成功");
		this.writeJson(jsondata);
		
		return null;
		
	}
	
	
	public String merge() {
		JsonData jsondata = new JsonData();
		if(null == dictModel.getDictId()) {
			this.dictService.add(dictModel);
			jsondata.setCode(0);
			jsondata.setMessage("增加成功");
		}else {
			this.dictService.edit(dictModel);
			jsondata.setCode(0);
			jsondata.setMessage("修改成功");
		}
		this.writeJson(jsondata);
		
		return null;
		
	}
}

4.前端Vue+Element-UI源代码:

main.js:

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

//开发环境下才会引入mockjs
//process.env.MOCK && require('@/mock')

import ElementUI from 'element-ui' //新添加1
import 'element-ui/lib/theme-chalk/index.css' //新添加2,避免后期打包样式不同,要放在import App from './App';之前
import App from './App'
import router from './router'


import axios  from '@/api/http'
import VueAxios from 'vue-axios'
Vue.use(VueAxios,axios)


Vue.use(ElementUI)   //新添加3
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  data:{
      //自定义的事件总线对象,用于父子组件的通信
      		Bus: new Vue()
  },
  components: {
    App
  },
  template: ''
})


export default axios;

App.vue:






index.js:

import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/views/Login'
import Main from '@/views/Main'
import AppMain from '@/sys/AppMain'//动态树页面
import User from '@/sys/User'//动态树子用户页面
import Uilr from '@/bas/Uilr'//动态树子字典页面
import Role from '@/sys/Role'//动态树子会员页面



Vue.use(Router)

export default new Router({
  routes: [
		{
			path: '/',
			name: 'Main',
			component: Main
		},
		{
			path: '/Login',
			name: 'Login',
			component: Login
		},
		{
			path: '/AppMain',
			name: 'AppMain',
			component: AppMain,
      children:[
        {
          path: 'Uilr',
          name: 'Uilr',
          component: Uilr
      },{
          path: 'User',
          name: 'User',
          component: User
      },{
          path: 'Role',
          name: 'Role',
          component: Role
      }]
		}]
})

登陆页面Login.vue:






前后端接口文件:
SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第7张图片

action.js

/**
 * 对后台请求的地址的封装,URL格式如下:
 * 模块名_实体名_操作
 */
export default {
	//服务器
	'SERVER': 'http://localhost:8080/vueSPA',

	//用户管理
	'SYS_USER_LOGIN': '/sys/userAction.action', //登陆
	/* 'SYS_USER_DOREG': '/sys/userAction_doReg.action', //注册
	'SYS_USER_LIST': '/sys/userAction_list.action', //用户查询
	'SYS_USER_DORESETPWD': '/sys/userAction_doResetPwd.action', //重置密码 */

	//文章管理
	'SYS_ARTICLES_ADD': '/sys/articlesAction_add.action',
	'SYS_ARTICLES_EDIT': '/sys/articlesAction_edit.action',
	'SYS_ARTICLES_DEL': '/sys/articlesAction_del.action',
	'SYS_ARTICLES_LOAD': '/sys/articlesAction_load.action',
	'SYS_ARTICLES_LIST': '/sys/articlesAction_list.action',

	//菜单管理
	'SYS_TREENODE_BOOTS': '/sys/TreeNodeAction_Boots.action',//动态树action
  //文章管理
  'BAS_UILR_LIST': '/bas/dictAction_list.action',
  //字典状态
  'BAS_UILR_UPDICTISEDITABLE': '/bas/dictAction_editdictIsEditable.action',
  //修改状态
  'BAS_UILR_MERGE': '/bas/dictAction_merge.action',
  //删除状态
  'BAS_UILR_DEL': '/bas/dictAction_del.action',

	//获得请求的完整地址,用于mockjs测试时使用
	'getFullPath': k => {
		return this.SERVER + this[k];
	}
}

http.js

/**
 * vue项目对axios的全局配置
 */
import axios from 'axios'
import qs from 'qs'

//引入action模块,并添加至axios的类属性urls上
import action from '@/api/action'
axios.urls = action

// axios默认配置
axios.defaults.timeout = 10000; // 超时时间
// axios.defaults.baseURL = 'http://localhost:8080/j2ee15'; // 默认地址
axios.defaults.baseURL = action.SERVER;

//整理数据
// 只适用于 POST,PUT,PATCH,transformRequest` 允许在向服务器发送前,修改请求数据
axios.defaults.transformRequest = function(data) {
	data = qs.stringify(data);
	return data;
};


// 请求拦截器
axios.interceptors.request.use(function(config) {
	return config;
}, function(error) {
	return Promise.reject(error);
});

// 响应拦截器
axios.interceptors.response.use(function(response) {
	return response;
}, function(error) {
	return Promise.reject(error);
});

// // 路由请求拦截
// // http request 拦截器
// axios.interceptors.request.use(
// 	config => {
// 		//config.data = JSON.stringify(config.data);  
// 		//config.headers['Content-Type'] = 'application/json;charset=UTF-8';
// 		//config.headers['Token'] = 'abcxyz';
// 		//判断是否存在ticket,如果存在的话,则每个http header都加上ticket
// 		// if (cookie.get("token")) {
// 		// 	//用户每次操作,都将cookie设置成2小时
// 		// 	cookie.set("token", cookie.get("token"), 1 / 12)
// 		// 	cookie.set("name", cookie.get("name"), 1 / 12)
// 		// 	config.headers.token = cookie.get("token");
// 		// 	config.headers.name = cookie.get("name");
// 		// }
// 		return config;
// 	},
// 	error => {
// 		return Promise.reject(error.response);
// 	});

// // 路由响应拦截
// // http response 拦截器
// axios.interceptors.response.use(
// 	response => {
// 		if (response.data.resultCode == "404") {
// 			console.log("response.data.resultCode是404")
// 			// 返回 错误代码-1 清除ticket信息并跳转到登录页面
// 			//      cookie.del("ticket")
// 			//      window.location.href='http://login.com'
// 			return
// 		} else {
// 			return response;
// 		}
// 	},
// 	error => {
// 		return Promise.reject(error.response) // 返回接口返回的错误信息
// 	});



export default axios;

后台模块主页面AppMain.vue:





顶部菜单TopNav.vue:






左侧菜单LeftNav.vue:









子菜单Role.vue:






子菜单User.vue:






子菜单Uilr.vue (CRUD造作页面+分页+动态数据+搜索栏+UD状态修改):






前端VUE+Element-UI+Axios+Node.js版本依赖:

SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第8张图片

package.json源码:

{
  "name": "test1",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "hjj",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "build": "node build/build.js"
  },
  "dependencies": {//生产
    "axios": "^0.19.2",
    "element-ui": "^2.13.1",
    "qs": "^6.9.4",
    "vue": "^2.5.2",
    "vue-axios": "^2.1.5",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {//开发
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "mockjs": "^1.1.0",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

项目发布(前后端分离)
SSH2(后台管理页面+Vue+Element-UI+动态树+分页+正则表达)_第9张图片

!!!!!!!!有报错无法解决----》作死@博主

你可能感兴趣的:(Vue,vue,spring,hibernate,node.js,es6)