栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

基于SSM+MySQL+Bootstrap的权限管理系统

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于SSM+MySQL+Bootstrap的权限管理系统

登录

首页

用户管理

密码重置

更改用户

添加角色

角色管理

发布文章

日志查看

druid

技术描述

开发工具: Idea/Eclipse
数据库: mysql
Jar包仓库: Maven
前段框架:jquery/Jsp
后端框架: Spring+SpringMVC+Mybatis

资料说明

基于SSM+MySQL+Bootstrap的权限管理系统,分为管理员,测试管理员等多个自定义角色。包含用户管理,权限管理,文章管理,日志管理,文件管理等。

package com.xe.demo.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.xe.demo.common.exception.AjaxLoginException;
import com.xe.demo.common.exception.AjaxPermissionException;
import com.xe.demo.common.exception.LoginException;
import com.xe.demo.common.exception.MalciousException;
import com.xe.demo.common.exception.PermissionException;
import com.xe.demo.common.pojo.AjaxResult;
import com.xe.demo.common.pojo.ParamData;
import com.xe.demo.common.utils.IPUtil;


@Controller
public class BaseController {

	
	public static Logger logger = LoggerFactory.getLogger(BaseController.class);

	
	public AjaxResult returnFailed(String retmsg) {
		return new AjaxResult(retmsg);
	}

	
	public static HttpServletRequest getRequest() {
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
	}

	
	@ExceptionHandler({ AjaxLoginException.class })
	@ResponseBody
	public AjaxResult ajaxLoginExceptionHandler(AjaxLoginException e) {
		logger.error("登录请求发生异常:", e);
		return new AjaxResult(e.getKey(), e.getMessage());
	}

	
	@ExceptionHandler({ LoginException.class })
	public String loginExceptionHandler(LoginException e, HttpServletRequest request) {
		logger.error("登录请求发生异常:", e);
		request.setAttribute("err", e.getMessage());
		return "forward:/";
	}

	
	@ExceptionHandler({ PermissionException.class })
	public String permissonExceptionHandler(PermissionException e) {
		return "common/no_permisson";
	}

	
	@ExceptionHandler({ AjaxPermissionException.class })
	@ResponseBody
	public AjaxResult ajaxPermissionExceptionHandler(AjaxPermissionException e) {
		return new AjaxResult(e.getKey(), e.getMessage());
	}
	
	
	@ExceptionHandler({ MalciousException.class })
	public String malExceptionHandler(MalciousException e) {
		return "common/mal_request";
	}

	
	@ExceptionHandler({ Exception.class })
	public Object exceptionHandler(Exception e, HttpServletRequest request) {
		ParamData params = new ParamData();
		logger.info("");
		StringBuilder sb = new StringBuilder(params.getString("loginIp")).append(request.getRequestURI()).append("请求发生异常:")
				.append(request.getServletPath()).append(":").append(params);
		logger.error(sb.toString(), e);
		return "common/500";
	}

	public void logBefore(String desc) {
		HttpServletRequest request = getRequest();
		logger.error("");
		StringBuilder sb = new StringBuilder(IPUtil.getIpAdd(request)).append(desc).append(":").append(request.getServletPath());
		logger.error(sb.toString());
	}
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1020649.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号