diff --git a/README.md b/README.md index 8c791482..119ab461 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![GitHub stars](https://img.shields.io/github/stars/shuzheng/zheng.svg?style=social&label=Stars)](https://github.com/shuzheng/zheng) [![GitHub forks](https://img.shields.io/github/forks/shuzheng/zheng.svg?style=social&label=Fork)](https://github.com/shuzheng/zheng) -交流QQ群:133107819🈵、284280411、305155242(群内含各种工具、文档、视频教程下载) +交流QQ群:133107819🈵、284280411🈵、305155242🈵、528049386、157869467(群内含各种工具、文档、视频教程下载) ## 前言 @@ -16,7 +16,66 @@ ### 组织结构 -![组织结构](project-bootstrap/zheng_project.png) +``` lua +zheng +├── zheng-common -- SSM框架公共模块 +├── zheng-admin -- 后台管理模板 +├── zheng-ui -- 前台thymeleaf模板[端口:1000] +├── zheng-config -- 配置中心[端口:1001] +├── zheng-upms -- 用户权限管理系统 +| ├── zheng-upms-common -- upms系统公共模块 +| ├── zheng-upms-dao -- 代码生成模块,无需开发 +| ├── zheng-upms-client -- 集成upms依赖包,提供单点认证、授权、统一会话管理 +| ├── zheng-upms-rpc-api -- rpc接口包 +| ├── zheng-upms-rpc-service -- rpc服务提供者 +| └── zheng-upms-server -- 用户权限系统及SSO服务端[端口:1111] +├── zheng-cms -- 内容管理系统 +| ├── zheng-cms-common -- cms系统公共模块 +| ├── zheng-cms-dao -- 代码生成模块,无需开发 +| ├── zheng-cms-rpc-api -- rpc接口包 +| ├── zheng-cms-rpc-service -- rpc服务提供者 +| ├── zheng-cms-search -- 搜索服务[端口:2221] +| ├── zheng-cms-admin -- 后台管理[端口:2222] +| ├── zheng-cms-job -- 消息队列、任务调度等[端口:2223] +| └── zheng-cms-web -- 网站前台[端口:2224] +├── zheng-pay -- 支付系统 +| ├── zheng-pay-common -- pay系统公共模块 +| ├── zheng-pay-dao -- 代码生成模块,无需开发 +| ├── zheng-pay-rpc-api -- rpc接口包 +| ├── zheng-pay-rpc-service -- rpc服务提供者 +| ├── zheng-pay-sdk -- 开发工具包 +| ├── zheng-pay-admin -- 后台管理[端口:3331] +| └── zheng-pay-web -- 演示示例[端口:3332] +├── zheng-ucenter -- 用户系统(包括第三方登录) +| ├── zheng-ucenter-common -- ucenter系统公共模块 +| ├── zheng-ucenter-dao -- 代码生成模块,无需开发 +| ├── zheng-ucenter-rpc-api -- rpc接口包 +| ├── zheng-ucenter-rpc-service -- rpc服务提供者 +| └── zheng-ucenter-web -- 网站前台[端口:4441] +├── zheng-wechat -- 微信系统 +| ├── zheng-wechat-mp -- 微信公众号管理系统 +| | ├── zheng-wechat-mp-dao -- 代码生成模块,无需开发 +| | ├── zheng-wechat-mp-service -- 业务逻辑 +| | └── zheng-wechat-mp-admin -- 后台管理[端口:5551] +| └── zheng-ucenter-app -- 微信小程序后台 +├── zheng-api -- API接口总线系统 +| ├── zheng-api-common -- api系统公共模块 +| ├── zheng-api-rpc-api -- rpc接口包 +| ├── zheng-api-rpc-service -- rpc服务提供者 +| └── zheng-api-server -- api系统服务端[端口:6666] +├── zheng-oss -- 对象存储系统 +| ├── zheng-oss-sdk -- 开发工具包 +| ├── zheng-oss-web -- 前台接口[端口:7771] +| └── zheng-oss-admin -- 后台管理[端口:7772] +├── zheng-shop -- 电子商务系统 +├── zheng-im -- 即时通讯系统 +├── zheng-oa -- 办公自动化系统 +├── zheng-eoms -- 运维系统 +└── zheng-demo -- 示例模块(包含一些示例代码等) + ├── zheng-demo-rpc-api -- rpc接口包 + ├── zheng-demo-rpc-service -- rpc服务提供者 + └── zheng-demo-web -- 演示示例[端口:8888] +``` ### 技术选型 @@ -228,6 +287,8 @@ maven编译安装zheng/pom.xml文件即可 - 修改各dao模块和rpc-service模块的redis.properties、jdbc.properties、generator.properties数据库连接等配置信息,其中master.redis.password、master.jdbc.password、slave.jdbc.password、generator.jdbc.password密码值使用了AES加密,请使用com.zheng.common.util.AESUtil工具类修改这些值 +- 启动Zookeeper、Redis、ActiveMQ、Nginx(配置文件参考project-tools/nginx下的*.conf文件) + > **zheng-upms** - 首先启动 zheng-upms-rpc-service(直接运行src目录下的ZhengUpmsRpcServiceApplication#main方法启动) => zheng-upms-server(jetty),然后按需启动对应子系统xxx的zheng-xxx-rpc-service(main方法) => zheng-xxx-webapp(jetty) @@ -263,7 +324,15 @@ maven编译安装zheng/pom.xml文件即可 - 已包含抽象类BaseServiceImpl,只需要继承抽象类并传入泛型参数,即可默认实现mapper接口所有方法,特殊需求直接扩展即可 - - BaseServiceImpl默认已实现`selectByExampleWithBLOBsForStartPage()`、`selectByExampleForStartPage()`、`selectByExampleWithBLOBsForOffsetPage()`、`selectByExampleForOffsetPage()`四种根据条件分页接口 + - BaseServiceImpl默认已实现四种根据条件分页接口 + + - selectByExampleWithBLOBsForStartPage() + + - selectByExampleForStartPage() + + - selectByExampleWithBLOBsForOffsetPage() + + - selectByExampleForOffsetPage() - BaseServiceImpl方法根据读写操作自动切换主从数据源,继承的扩展接口,可手动通过`DynamicDataSource.setDataSource(DataSourceEnum.XXX.getName())`指定数据源 diff --git a/project-bootstrap/README.md b/project-bootstrap/README.md index 8773e267..9ca1b490 100644 --- a/project-bootstrap/README.md +++ b/project-bootstrap/README.md @@ -1,66 +1,3 @@ # project-bootstrap -本目录为项目介绍资源目录,包含模块依赖图、拓扑图等 - - -### 组织结构 - -``` lua -zheng -├── zheng-common -- SSM框架公共模块 -├── zheng-admin -- 后台管理模板 -├── zheng-ui -- 前台thymeleaf模板[端口:1000] -├── zheng-upms -- 用户权限管理系统 -| ├── zheng-upms-common -- upms系统公共模块 -| ├── zheng-upms-dao -- 代码生成模块,无需开发 -| ├── zheng-upms-client -- 集成upms依赖包,提供单点认证、授权、统一会话管理 -| ├── zheng-upms-rpc-api -- rpc接口包 -| ├── zheng-upms-rpc-service -- rpc服务提供者 -| └── zheng-upms-server -- 用户权限系统及SSO服务端[端口:1111] -├── zheng-cms -- 内容管理系统 -| ├── zheng-cms-common -- cms系统公共模块 -| ├── zheng-cms-dao -- 代码生成模块,无需开发 -| ├── zheng-cms-rpc-api -- rpc接口包 -| ├── zheng-cms-rpc-service -- rpc服务提供者 -| ├── zheng-cms-search -- 搜索服务[端口:2221] -| ├── zheng-cms-admin -- 后台管理[端口:2222] -| ├── zheng-cms-job -- 消息队列、任务调度等[端口:2223] -| └── zheng-cms-web -- 网站前台[端口:2224] -├── zheng-pay -- 支付系统 -| ├── zheng-pay-common -- pay系统公共模块 -| ├── zheng-pay-dao -- 代码生成模块,无需开发 -| ├── zheng-pay-rpc-api -- rpc接口包 -| ├── zheng-pay-rpc-service -- rpc服务提供者 -| ├── zheng-pay-sdk -- 开发工具包 -| ├── zheng-pay-admin -- 后台管理[端口:3331] -| └── zheng-pay-web -- 演示示例[端口:3332] -├── zheng-ucenter -- 用户系统(包括第三方登录) -| ├── zheng-ucenter-common -- ucenter系统公共模块 -| ├── zheng-ucenter-dao -- 代码生成模块,无需开发 -| ├── zheng-ucenter-rpc-api -- rpc接口包 -| ├── zheng-ucenter-rpc-service -- rpc服务提供者 -| └── zheng-ucenter-web -- 网站前台[端口:4441] -├── zheng-wechat -- 微信系统 -| ├── zheng-wechat-mp -- 微信公众号管理系统 -| | ├── zheng-wechat-mp-dao -- 代码生成模块,无需开发 -| | ├── zheng-wechat-mp-service -- 业务逻辑 -| | └── zheng-wechat-mp-admin -- 后台管理[端口:5551] -| └── zheng-ucenter-app -- 微信小程序后台 -├── zheng-api -- API接口总线系统 -| ├── zheng-api-common -- api系统公共模块 -| ├── zheng-api-rpc-api -- rpc接口包 -| ├── zheng-api-rpc-service -- rpc服务提供者 -| └── zheng-api-server -- api系统服务端[端口:6666] -├── zheng-oss -- 对象存储系统 -| ├── zheng-oss-sdk -- 开发工具包 -| ├── zheng-oss-web -- 前台接口[端口:7771] -| └── zheng-oss-admin -- 后台管理[端口:7772] -├── zheng-shop -- 电子商务系统 -├── zheng-im -- 即时通讯系统 -├── zheng-oa -- 办公自动化系统 -├── zheng-eoms -- 运维系统 -└── zheng-demo -- 示例模块(包含一些示例代码等) - ├── zheng-demo-rpc-api -- rpc接口包 - ├── zheng-demo-rpc-service -- rpc服务提供者 - └── zheng-demo-web -- 演示示例[端口:8888] -``` \ No newline at end of file +本目录为项目介绍资源目录,包含模块依赖图、拓扑图等 \ No newline at end of file diff --git a/project-bootstrap/zheng_project.png b/project-bootstrap/zheng_project.png deleted file mode 100644 index c846e8d2..00000000 Binary files a/project-bootstrap/zheng_project.png and /dev/null differ diff --git a/zheng-common/src/main/java/com/zheng/common/util/CaptchaUtil.java b/zheng-common/src/main/java/com/zheng/common/util/CaptchaUtil.java new file mode 100644 index 00000000..71fc396f --- /dev/null +++ b/zheng-common/src/main/java/com/zheng/common/util/CaptchaUtil.java @@ -0,0 +1,237 @@ +package com.zheng.common.util; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Random; + +/** + * 验证码工具类 + * Created by ZhangShuzheng on 2017/6/28. + */ +public class CaptchaUtil { + // 图片的宽度。 + private int width = 160; + // 图片的高度。 + private int height = 40; + // 验证码字符个数 + private int codeCount = 4; + // 验证码干扰线数 + private int lineCount = 20; + // 验证码 + private String code = null; + // 验证码图片Buffer + private BufferedImage buffImg = null; + Random random = new Random(); + + public CaptchaUtil() { + creatImage(); + } + + public CaptchaUtil(int width, int height) { + this.width = width; + this.height = height; + creatImage(); + } + + public CaptchaUtil(int width, int height, int codeCount) { + this.width = width; + this.height = height; + this.codeCount = codeCount; + creatImage(); + } + + public CaptchaUtil(int width, int height, int codeCount, int lineCount) { + this.width = width; + this.height = height; + this.codeCount = codeCount; + this.lineCount = lineCount; + creatImage(); + } + + // 生成图片 + private void creatImage() { + int fontWidth = width / codeCount;// 字体的宽度 + int fontHeight = height - 5;// 字体的高度 + int codeY = height - 8; + + // 图像buffer + buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics g = buffImg.getGraphics(); + //Graphics2D g = buffImg.createGraphics(); + // 设置背景色 + g.setColor(getRandColor(200, 250)); + g.fillRect(0, 0, width, height); + + + // 设置字体 + //Font font1 = getFont(fontHeight); + Font font = new Font("Fixedsys", Font.BOLD, fontHeight); + g.setFont(font); + + // 设置干扰线 + for (int i = 0; i < lineCount; i++) { + int xs = random.nextInt(width); + int ys = random.nextInt(height); + int xe = xs + random.nextInt(width); + int ye = ys + random.nextInt(height); + g.setColor(getRandColor(1, 255)); + g.drawLine(xs, ys, xe, ye); + } + + // 添加噪点 + float yawpRate = 0.01f;// 噪声率 + int area = (int) (yawpRate * width * height); + for (int i = 0; i < area; i++) { + int x = random.nextInt(width); + int y = random.nextInt(height); + + buffImg.setRGB(x, y, random.nextInt(255)); + } + + String str1 = randomStr(codeCount);// 得到随机字符 + this.code = str1; + for (int i = 0; i < codeCount; i++) { + String strRand = str1.substring(i, i + 1); + g.setColor(getRandColor(1, 255)); + // g.drawString(a,x,y); + // a为要画出来的东西,x和y表示要画的东西最左侧字符的基线位于此图形上下文坐标系的 (x, y) 位置处 + + g.drawString(strRand, i * fontWidth + 3, codeY); + } + } + + // 得到随机字符 + private String randomStr(int n) { + String str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; + String str2 = ""; + int len = str1.length() - 1; + double r; + for (int i = 0; i < n; i++) { + r = (Math.random()) * len; + str2 = str2 + str1.charAt((int) r); + } + return str2; + } + + // 得到随机颜色 + private Color getRandColor(int fc, int bc) {// 给定范围获得随机颜色 + if (fc > 255) + fc = 255; + if (bc > 255) + bc = 255; + int r = fc + random.nextInt(bc - fc); + int g = fc + random.nextInt(bc - fc); + int b = fc + random.nextInt(bc - fc); + return new Color(r, g, b); + } + + /** + * 产生随机字体 + */ + private Font getFont(int size) { + Random random = new Random(); + Font font[] = new Font[5]; + font[0] = new Font("Ravie", Font.PLAIN, size); + font[1] = new Font("Antique Olive Compact", Font.PLAIN, size); + font[2] = new Font("Fixedsys", Font.PLAIN, size); + font[3] = new Font("Wide Latin", Font.PLAIN, size); + font[4] = new Font("Gill Sans Ultra Bold", Font.PLAIN, size); + return font[random.nextInt(5)]; + } + + // 扭曲方法 + private void shear(Graphics g, int w1, int h1, Color color) { + shearX(g, w1, h1, color); + shearY(g, w1, h1, color); + } + + private void shearX(Graphics g, int w1, int h1, Color color) { + + int period = random.nextInt(2); + + boolean borderGap = true; + int frames = 1; + int phase = random.nextInt(2); + + for (int i = 0; i < h1; i++) { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + + (6.2831853071795862D * (double) phase) + / (double) frames); + g.copyArea(0, i, w1, 1, (int) d, 0); + if (borderGap) { + g.setColor(color); + g.drawLine((int) d, i, 0, i); + g.drawLine((int) d + w1, i, w1, i); + } + } + } + + private void shearY(Graphics g, int w1, int h1, Color color) { + + int period = random.nextInt(40) + 10; // 50; + + boolean borderGap = true; + int frames = 20; + int phase = 7; + for (int i = 0; i < w1; i++) { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + + (6.2831853071795862D * (double) phase) + / (double) frames); + g.copyArea(i, 0, 1, h1, 0, (int) d); + if (borderGap) { + g.setColor(color); + g.drawLine(i, (int) d, i, 0); + g.drawLine(i, (int) d + h1, i, h1); + } + } + } + + public void write(OutputStream sos) throws IOException { + ImageIO.write(buffImg, "png", sos); + sos.close(); + } + + public BufferedImage getBuffImg() { + return buffImg; + } + + public String getCode() { + return code.toLowerCase(); + } + +// /** +// * 验证码 +// * @param request +// * @param response +// * @param session +// * @throws IOException +// */ +// @RequestMapping("/code.jpg") +// public void getCode3(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException { +// int width = NumberUtils.toInt(request.getParameter("width"), 100); +// int height = NumberUtils.toInt(request.getParameter("height"), 30); +// int codeCount = NumberUtils.toInt(request.getParameter("codeCount"), 4); +// int lineCount = NumberUtils.toInt(request.getParameter("lineCount"), 10); +// if (width > 1000) width = 100; +// if (height > 300) height = 30; +// if (codeCount > 10) codeCount = 4; +// if (lineCount > 100) lineCount = 10; +// // 设置响应的类型格式为图片格式 +// response.setContentType("image/jpeg"); +// // 禁止图像缓存。 +// response.setHeader("Pragma", "no-cache"); +// response.setHeader("Cache-Control", "no-cache"); +// response.setDateHeader("Expires", 0); +// // 自定义参数 +// CaptchaUtil code = new CaptchaUtil(width, height, codeCount, lineCount); +// String sessionId = session.getId(); +// RedisUtil.set("captcha_" + sessionId, code.getCode(), 60 * 30); +// code.write(response.getOutputStream()); +// } + +} diff --git a/zheng-common/src/main/java/com/zheng/common/util/MybatisGeneratorUtil.java b/zheng-common/src/main/java/com/zheng/common/util/MybatisGeneratorUtil.java index 48efbc4e..021c8f29 100644 --- a/zheng-common/src/main/java/com/zheng/common/util/MybatisGeneratorUtil.java +++ b/zheng-common/src/main/java/com/zheng/common/util/MybatisGeneratorUtil.java @@ -56,7 +56,9 @@ public class MybatisGeneratorUtil { serviceImpl_vm = MybatisGeneratorUtil.class.getResource(serviceImpl_vm).getPath().replaceFirst("/", ""); String targetProject = module + "/" + module + "-dao"; - String module_path = module + "/" + module + "-dao/src/main/resources/generatorConfig.xml"; + String basePath = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "").replace(targetProject, "").replaceFirst("/", ""); + String generatorConfig_xml = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "") + "/src/main/resources/generatorConfig.xml"; + targetProject = basePath + targetProject; String sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" + database + "' AND table_name LIKE '" + table_prefix + "_%';"; System.out.println("========== 开始生成generatorConfig.xml文件 =========="); @@ -77,7 +79,7 @@ public class MybatisGeneratorUtil { } jdbcUtil.release(); - String targetProject_sqlMap = module + "/" + module + "-rpc-service"; + String targetProject_sqlMap = basePath + module + "/" + module + "-rpc-service"; context.put("tables", tables); context.put("generator_javaModelGenerator_targetPackage", package_name + ".dao.model"); context.put("generator_sqlMapGenerator_targetPackage", package_name + ".dao.mapper"); @@ -86,7 +88,7 @@ public class MybatisGeneratorUtil { context.put("targetProject_sqlMap", targetProject_sqlMap); context.put("generator_jdbc_password", AESUtil.AESDecode(jdbc_password)); context.put("last_insert_id_tables", last_insert_id_tables); - VelocityUtil.generate(generatorConfig_vm, module_path, context); + VelocityUtil.generate(generatorConfig_vm, generatorConfig_xml, context); // 删除旧代码 deleteDir(new File(targetProject + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/dao/model")); deleteDir(new File(targetProject + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/dao/mapper")); @@ -98,7 +100,7 @@ public class MybatisGeneratorUtil { System.out.println("========== 开始运行MybatisGenerator =========="); List warnings = new ArrayList<>(); - File configFile = new File(module_path); + File configFile = new File(generatorConfig_xml); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(true); @@ -111,8 +113,8 @@ public class MybatisGeneratorUtil { System.out.println("========== 开始生成Service =========="); String ctime = new SimpleDateFormat("yyyy/M/d").format(new Date()); - String servicePath = module + "/" + module + "-rpc-api" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/api"; - String serviceImplPath = module + "/" + module + "-rpc-service" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/service/impl"; + String servicePath = basePath + module + "/" + module + "-rpc-api" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/api"; + String serviceImplPath = basePath + module + "/" + module + "-rpc-service" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/service/impl"; for (int i = 0; i < tables.size(); i++) { String model = StringUtil.lineToHump(ObjectUtils.toString(tables.get(i).get("table_name"))); String service = servicePath + "/" + model + "Service.java"; diff --git a/zheng-common/src/main/resources/template/generatorConfig.vm b/zheng-common/src/main/resources/template/generatorConfig.vm index f223a925..31c4f1bc 100644 --- a/zheng-common/src/main/resources/template/generatorConfig.vm +++ b/zheng-common/src/main/resources/template/generatorConfig.vm @@ -60,7 +60,6 @@ - #foreach($table in $tables) #if($last_insert_id_tables.containsKey($!table.table_name) == true) diff --git a/zheng-upms/zheng-upms-client/src/main/java/com/zheng/upms/client/interceptor/LogAspect.java b/zheng-upms/zheng-upms-client/src/main/java/com/zheng/upms/client/interceptor/LogAspect.java index c57907fc..bd9b2a14 100644 --- a/zheng-upms/zheng-upms-client/src/main/java/com/zheng/upms/client/interceptor/LogAspect.java +++ b/zheng-upms/zheng-upms-client/src/main/java/com/zheng/upms/client/interceptor/LogAspect.java @@ -1,5 +1,6 @@ package com.zheng.upms.client.interceptor; +import com.alibaba.fastjson.JSON; import com.zheng.common.util.RequestUtil; import com.zheng.upms.dao.model.UpmsLog; import com.zheng.upms.rpc.api.UpmsApiService; @@ -87,7 +88,7 @@ public class LogAspect { } else { upmsLog.setParameter(ObjectUtils.toString(request.getParameterMap())); } - upmsLog.setResult(ObjectUtils.toString(result)); + upmsLog.setResult(JSON.toJSONString(result)); upmsLog.setSpendTime((int) (endTime - startTime)); upmsLog.setStartTime(startTime); upmsLog.setUri(request.getRequestURI()); diff --git a/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java b/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java index 672377bd..9648ff07 100644 --- a/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java +++ b/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java @@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; /** - * 用户service实现 + * UpmsApiService实现 * Created by shuzheng on 2016/01/19. */ @Service diff --git a/zheng-upms/zheng-upms-server/pom.xml b/zheng-upms/zheng-upms-server/pom.xml index f79f306e..406d7e5a 100644 --- a/zheng-upms/zheng-upms-server/pom.xml +++ b/zheng-upms/zheng-upms-server/pom.xml @@ -33,8 +33,8 @@ javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 provided diff --git a/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java new file mode 100644 index 00000000..0465747c --- /dev/null +++ b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java @@ -0,0 +1,22 @@ +package com.zheng.upms.server; + +import javax.servlet.DispatcherType; +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + + +/** + * 强制进行转码过滤器 + * Created by shuzheng on 2017/6/24. + */ +@WebFilter( + filterName = "CharacterEncodingFilter", + urlPatterns = "/*", + dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD}, + initParams = { + @WebInitParam(name = "encoding", value = "UTF-8") + } +) +public class CharacterEncodingFilter extends org.springframework.web.filter.CharacterEncodingFilter { + +} diff --git a/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java new file mode 100644 index 00000000..610364db --- /dev/null +++ b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java @@ -0,0 +1,20 @@ +package com.zheng.upms.server; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + + +/** + * shiroFilter + * Created by shuzheng on 2017/6/24. + */ +@WebFilter( + filterName = "shiroFilter", + urlPatterns = "/*", + initParams = { + @WebInitParam(name = "targetFilterLifecycle", value = "true") + } +) +public class ShiroFilter extends org.springframework.web.filter.DelegatingFilterProxy { + +} diff --git a/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml b/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml index c36b5ed7..316247f1 100644 --- a/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml +++ b/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml @@ -4,22 +4,6 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> - - - CharacterEncodingFilter - org.springframework.web.filter.CharacterEncodingFilter - - encoding - UTF-8 - - - - CharacterEncodingFilter - /* - REQUEST - FORWARD - - org.springframework.web.context.ContextLoaderListener @@ -53,18 +37,18 @@ - - shiroFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetFilterLifecycle - true - - - - shiroFilter - /* - + + + + + + + + + + + +