恋梦红尘
楼主
发布于 2023-5-27 09:33:24
阅读 2249
查看全部
文章目录
前言一、项目构造
二、项目配置文件
pom.xmlresouerces
mapper文件
AdminMapper.xmlMyFileMapper.xmlUsersMapper.xmlOrdersMapper.xml(订单 表映射)RoleMapper.xml
application.xml(整合所有容器)db.properties(mysql配置)logj.properties(日志容器)mybits-config.xml(存储过程及映射)spring-dao.xmlspring-mvc.xmlspring-service.xmlspring-shiro.xml
三、后端功能实现
1.实体层(entity)2.耐久层(mapper)又称dao层3.业务层(service)
4.控制层(controller)5.工具层(utils)6.登录实现层(realm)
四、前端功能实现
1.static(前端静态资源显示)2.upOA d(文件上传目录)3.jsp(显示页面格式为:xxx.jsp)
总结
前言
开发工具:IntelliJ IDEA 2019.3.1
本文用到的技术:layui+ajax+SSM(Spring+SpringMVC+MyBatis)+mysql+tomcat
编写语言为:Java
由于本位篇幅过长,我这里提供两种下载地址。
码云仓库(gitee):https://gitee.com/fishme9/logistics_system.git
百度网盘:https://pan.baidu.com/s/1fgMG89ZpohAVRgk1fHeOPQ?pwd=58e2
提取码:58e2
MySQL文件:
百度网盘:https://pan.baidu.com/s/1SIOKTboJe4MWV6z15mFL0A?pwd=0ymg
提取码:0ymg
提示:以下是本篇文章正文内容,下面案例可供参考
一、项目构造
1.文件构造
这里有些文件没有显示,详细的目录下面有哪些文件显示,会在下面的详细实现中,展示出来。
2.部分显示效果图
用户列表
订单管理
管理员列表
文件上传下载
登录个人信息及密码修改
二、项目配置文件
pom.xml
maven依赖包<?xml version="1.0" encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.hqyj.psl</groupId><artifactId>ssmjavaweb</artifactId><version>1.0-SNAPSHOT</version><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build><packaging>war</packaging><dependencies><!--dao依赖--><!--mybatis相关--><!--1. mybatis--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.9</version></dependency><!--2.mybatis整合spring--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>2.0.7</version></dependency><!--3.mysql--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.47</version></dependency><!--4.lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.24</version></dependency><!--5.log4j--><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><!--6.junit--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency><!--7.spring相关--><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.3.19</version></dependency><!--spring-test--><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.3.19</version></dependency><!--spring-jdbc--><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>5.3.19</version></dependency><!--spring-tx--><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>5.3.19</version></dependency><!--service层--><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>1.9.7</version></dependency><!--Druid--><!-- https://mvnrepository.com/artifact/com.alibaba/druid --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.22</version></dependency><!--c3p0连接池--><dependency><groupId>com.mchange</groupId><artifactId>c3p0</artifactId><version>0.9.5.2</version></dependency><!--添加servlet的支持--><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version></dependency><!--json--><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.13.2</version></dependency><!--pagehelper 分页插件--><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.3.1</version></dependency><!-- pagehelper的依赖包:jsqlparser --><dependency><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId><version>4.5</version></dependency><!--文档上传下载依赖包--><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.1</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version></dependency><dependency><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId><version>1.9</version></dependency><!--shiro依赖相关--><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-all</artifactId><version>1.2.2</version></dependency><!--spring整合shiro的包--><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId><version>1.2.2</version></dependency></dependencies></project> 复制代码 resouerces
mapper文件
AdminMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.hqyj.psl.mapper.AdminMapper"><resultMapid="adminMap"type="Admin"><idproperty="adminId"column="id"/><resultproperty="sex"column="sex"/><resultproperty="name"column="name"/><resultproperty="phone"column="phone"/><resultproperty="email"column="email"/><resultproperty="remark"column="remark"/><resultproperty="username"column="username"/><resultproperty="password"column="password"/></resultMap><selectid="selectByName"resultMap="adminMap"> select * from admin where name=#{username} </select><!--通过名字查询角色--><selectid="selectRolesByUsername"resultType="java.lang.String"> SELECT r.name FROM admin_role ar left join admin a on a.admin_id=ar.admin_id left join role r on r.role_id=ar.role_id where a.name = #{name}; </select><!--通过名字查询权限--><selectid="selectPermsByUsername"resultType="java.lang.String"> select p.url from role_permission rp left join role r on r.role_id=rp.role_id left join permission p on p.permission_id=rp.permission_id where rp.role_id in (SELECT r.role_id FROM admin_role ar left join admin a on a.admin_id=ar.admin_id left join role r on r.role_id=ar.role_id where a.name = #{name}) </select><!--注册--><insertid="insertBySignup"> insert into admin (admin_id,name,username,password) values (null,#{arg0},"simple",#{arg1}) </insert><!--个人信息更新--><updateid="update"> update admin set phone=#{phone},email=#{email},password=#{password},remark=#{remark} where name=#{name} </update><!--个人资料查询--><selectid="show"resultMap="adminMap"> select * from admin where name=#{username} and password=#{password} </select></mapper> 复制代码 MyFileMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.hqyj.psl.mapper.MyFileMapper"><resultMapid="myFileMap"type="MyFile"><idproperty="fileId"column="file_id"/><resultproperty="fileName"column="file_name"/><resultproperty="fileUrl"column="file_url"/></resultMap><!--sql片段--><sqlid="myFileCol"> file_id,file_name,file_url </sql><!--查询文件--><selectid="selectAll"resultMap="myFileMap"> select * from my_file </select><!--添加文件内容到数据库--><insertid="insert"parameterType="MyFile"> insert into my_file values (null,#{fileName},#{fileUrl}) </insert><!--移除文件--><deleteid="deleteFile"> delete from my_file where file_id=#{fileId} </delete></mapper> 复制代码 UsersMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.hqyj.psl.mapper.UsersMapper"><!--1.结果映射--><resultMapid="usersMap"type="Users"><idproperty="usersId"column="users_id"/><resultproperty="name"column="name"/><resultproperty="sex"column="sex"/><resultproperty="address"column="address"/><resultproperty="phone"column="phone"/><resultproperty="email"column="email"/><resultproperty="username"column="username"/><resultproperty="password"column="password"/><resultproperty="isVip"column="is_vip"/><resultproperty="deleted"column="deleted"/><resultproperty="joinDate"column="join_time"/></resultMap><!--2.数据库字段片段--><sqlid="UsersCol"> users_id,name,sex,address,phone,email,username,password,is_vip,deleted,join_time </sql><!--分页查所有用户--><selectid="selectAll"resultMap="usersMap"> select <includerefid="UsersCol"/> from users where deleted = 0 </select><!--根据名称查询user--><selectid="selectOneByUsername"resultMap="usersMap"> select <includerefid="UsersCol"/> from user where username=#{username} </select><updateid="update"> update users set name=#{name},sex=#{sex},address=#{address}, phone=#{phone},email=#{email},username=#{username}, password=#{password},deleted=#{deleted},join_time=#{joinDate} where users_id=#{usersId} </update><!--逻辑删除--><updateid="deleteUpdByUserId"> update users set deleted = 1 where users_id=#{usersId} </update><deleteid="deleteByUserId"> delete from user where user_id=#{id} </delete><insertid="insert"> insert into users values (null,#{name},#{sex},#{address}, #{phone},#{email},#{username},#{password},#{isVip},#{deleted},#{joinDate}) </insert><selectid="search"resultMap="usersMap"> select * from users <where> deleted = 0 <iftest="username!=null and username!=''"> and username like CONCAT(CONCAT('%',#{username},'%')) </if><iftest="phone!=null and phone!=''"> and phone like CONCAT(CONCAT('%',#{phone},'%')) </if></where></select><!--逻辑删除全部--><updateid="deleteAll"parameterType="list"> update users set deleted=1 <where><foreachcollection="list"item="item"index="index"open="users_id in ("close=")"separator=","> #{item} </foreach></where></update><!--查找被逻辑删除的--><selectid="selectByDeletedUsers"resultMap="usersMap"> select <includerefid="UsersCol"/> from users where deleted = 1 </select><!--恢复删除--><updateid="renew"> update users set deleted = 0 where users_id = #{usersId} </update><!--全部恢复--><updateid="updateRenbit"parameterType="list"> update users set deleted = 0 <where><foreachcollection="list"item="item"index="index"open="users_id in ("close=")"separator=","> #{item} </foreach></where></update><!--删除--><deleteid="phyDel"> delete from users where users_id = #{usersId} </delete><!--条件查找--><selectid="condQuery"resultMap="usersMap"> select <includerefid="UsersCol"/> from users <where> deleted = 1 <iftest="username != '%%'"> and name like #{username} </if></where></select></mapper> 复制代码 OrdersMapper.xml(订单表映射)
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.hqyj.psl.mapper.OrdersMapper"><!--1.结果映射--><resultMapid="ordersMap"type="Orders"><idproperty="ordersId"column="orders_id"/><resultproperty="ordersNo"column="orders_no"/><resultproperty="ordersName"column="orders_name"/><resultproperty="phone"column="phone"/><resultproperty="totalAmount"column="total_amount"/><resultproperty="payAmount"column="pay_amount"/><resultproperty="ordersState"column="orders_state"/><resultproperty="payState"column="pay_state"/><resultproperty="shipmentsState"column="shipments_state"/><resultproperty="giveMethod"column="give_method"/><resultproperty="ordersTime"column="orders_time"/></resultMap><!--2.sql片段--><sqlid="ordersCol"> Orders,orders_id,orders_no,orders_name,phone,total_amount,pay_amount,orders_state,pay_state,shipments_state,give_method,orders_time </sql><selectid="selectAll"resultMap="ordersMap"> select * from orders </select><deleteid="delete"> delete from orders where orders_id = #{ordersId} </delete><updateid="update"> update orders set orders_name = #{ordersName},shipments_state = #{shipmentsState},give_method = #{giveMethod} where orders_id = #{ordersId} </update><updateid="insert"> insert into orders values (null,#{ordersNo},#{ordersName},#{phone},#{totalAmount},#{payAmount},#{ordersState},#{payState},#{shipmentsState},#{giveMethod},#{ordersTime}) </update><!--模糊查询--><selectid="selectLike"resultMap="ordersMap"> select * from orders <where><iftest="payState!=''"> and pay_state = #{payState} </if><iftest="ordersState!=''"> and orders_state = #{ordersState} </if><iftest="ordersNo!='%%'"> and orders_no like #{ordersNo} </if><iftest="isVip!=null"> and orders_id IN( SELECT orders_id FROM orders_users WHERE users_id IN ( SELECT users_id FROM users WHERE is_vip = #{isVip} )) </if></where></select><deleteid="deleteAll"parameterType="List"> delete from orders <where><foreachcollection="list"index="index"item="item"open="orders_id in ("close=")"separator=","> #{item} </foreach></where></delete></mapper> 复制代码 RoleMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.hqyj.psl.mapper.RoleMapper"><!--结果集--><resultMapid="adminVoMapper"type="AdminVo"><!--Role里面的字段--><idproperty="adminId"column="admin_id"/><resultproperty="username"column="username"/><resultproperty="rname"column="rname"/><resultproperty="url"column="url"/><!--Roles集合--><collectionproperty="roles"ofType="Role"><idproperty="roleId"column="role_id"/><resultproperty="name"column="rname"/><resultproperty="state"column="state"/></collection><!--Permission集合--><!-- <collection property="permissions" ofType="Permission">--><!-- <id property="permissionId" column="permission_id"/>--><!-- <result property="url" column="url"/>--><!-- <result property="state" column="pstate"/>--><!-- </collection>--></resultMap><!-- 根据用户名查询所有拥有的角色--><selectid="selectRolesByUsername"resultType="java.lang.String"> SELECT ad.*,r.`role_id`,r.`name` as rname,r.`state` FROM admin_role ar LEFT JOIN admin ad ON ad.`admin_id`=ar.`admin_id` LEFT JOIN role r ON r.`role_id`=ar.`role_id` WHERE ad.`username`=#{username} </select><!-- 查询所有角色--><selectid="selectRoleAll"resultMap="adminVoMapper"> SELECT role_id,NAME rname FROM role; </select><!-- <select id="selectRoleAll" resultMap="adminVoMapper">--><!-- SELECT ad.*, r.`name` rname,r.role_id,r.state FROM admin_role ar--><!-- LEFT JOIN admin ad ON ad.`admin_id`=ar.`admin_id`--><!-- LEFT JOIN role r ON r.`role_id`=ar.`role_id`--><!-- GROUP BY ad.`admin_id`;--><!-- </select>--><!--查询所有角色的admin_id--><!-- 根据角色查询所有拥有权限--><selectid="selectPermsByRole"resultType="java.lang.String"> SELECT p.`url` FROM role_permission rp LEFT JOIN role r ON rp.`role_id`=r.`role_id` LEFT JOIN permission p ON rp.`permission_id`=p.`permission_id` WHERE r.`role_id`=#{roleId}; </select><!--根据用户名查询所有拥有的权限--><selectid="selectPermsByUsername"resultMap="adminVoMapper"> SELECT DISTINCT p.url FROM role_permission rp LEFT JOIN role r ON r.role_id=rp.role_id LEFT JOIN permission p ON p.permission_id=rp.permission_id WHERE rp.role_id IN (SELECT r.role_id FROM admin_role ad LEFT JOIN admin a ON a.admin_id=ad.admin_id LEFT JOIN role r ON r.role_id=ad.role_id WHERE username = #{username}) </select><!--修改角色名--><selectid="updateRoleName"resultType="java.lang.Integer"> UPDATE role SET NAME=#{name} WHERE role_id=#{roleId} </select><!--修改权限--><!--删除权限关联表中的关联--><deleteid="deleteRole_P"> DELETE FROM role_permission WHERE role_id=#{roleId} </delete><!--根据权限名url查询权限id--><selectid="selectPreId"resultType="java.lang.Integer"> SELECT permission_id FROM permission WHERE url=#{url}; </select><!--添加权限关联表中的关联添加 preid roleId--><insertid="addRole_P"> INSERT INTO role_permission VALUES(null,#{arg0},#{arg1}); </insert><!--删除角色--><deleteid="deleteRole"> DELETE FROM role WHERE role_id=#{roleId} </delete><!--添加角色--><!--1.在Role表中添加角色名--><insertid="addRoleName"> INSERT INTO role VALUES(NULL,#{name},1); </insert><!--2.查询Role表中的roleId 通过角色名--><selectid="selectRoleByName"resultType="java.lang.Integer"> SELECT role_id FROM role WHERE NAME=#{name}; </select></mapper> 复制代码 application.xml(整合所有容器)
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"><!--整合容器--><importresource="classpath:spring-dao.xml"/><importresource="classpath:spring-service.xml"/><importresource="classpath:spring-mvc.xml"/><importresource="classpath:spring-shiro.xml"/></beans> 复制代码 db.properties(mysql配置)
driver=com.mysql.jdbc.Driver url=jdbc:mysql:///ssmweb user=root password=root #c3p0.minPoolSize = 10 #c3p0.maxPoolSize = 20 #c3p0.initialPoolSize = 100 #c3p0.maxIdleTime = 30 #c3p0.acquireIncrement = 5 复制代码 logj.properties(日志容器)
#假设要输出到文件,下面一行后面增加一个,File log4j.rootLogger=DEBUG, Console #配置输出log到文件 #文件大小到达指定尺寸的时候产生一个新的文件 log4j.appender.File = org.apache.log4j.RollingFileAppender #指定输出目录 log4j.appender.File.File = logs/ssm.log #定义文件最大大小 log4j.appender.File.MaxFileSize = 10MB # 输出所以日志,假设换成DEBUG表示输出DEBUG以上级别日志 log4j.appender.File.Threshold = ALL log4j.appender.File.layout = org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n #配置输出到Console log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=[%p][%c] - %m%n # spring框架和apache的包输出日志级别为INFO log4j.logger.org.springframework=INFO log4j.logger.org.apache=INFO 复制代码 mybits-config.xml(存储过程及映射)
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPEconfigurationPUBLIC"-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><!--设置日志及缓存--><settings><settingname="logImpl"value="LOG4J"/></settings><!--配置别名--><typeAliases><typeAliastype="com.hqyj.psl.entity.Users"alias="Users"/><typeAliastype="com.hqyj.psl.entity.MyFile"alias="MyFile"/><typeAliastype="com.hqyj.psl.entity.Admin"alias="Admin"/><typeAliastype="com.hqyj.psl.entity.Orders"alias="Orders"/><typeAliastype="com.hqyj.psl.entity.Role"alias="Role"/><typeAliastype="com.hqyj.psl.entity.AdminVo"alias="AdminVo"/><typeAliastype="com.hqyj.psl.entity.Permission"alias="Permission"/></typeAliases></configuration> 复制代码 spring-dao.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"><!--0.扫描包--><context:component-scanbase-package="com.hqyj.psl.mapper"/><!--1.引入db.properties--><context:property-placeholderlocation="classpath:db.properties"/><!--2.dataSource--><!-- druid连接--><beanid="dataSource"class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close"lazy-init="false"><propertyname="driverClassName"value="${driver}"/><propertyname="url"value="${url}"/><propertyname="username"value="${user}"/><propertyname="password"value="${password}"/><propertyname="initialSize"value="3"/><propertyname="maxActive"value="5"/><propertyname="maxWait"value="3000"/></bean><!--3.sqlSessionFactory--><beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="configLocation"value="classpath:mybatis-config.xml"/><propertyname="mapperLocations"value="classpath:mapper/*.xml"/><propertyname="plugins"><array><beanclass="com.github.pagehelper.PageInterceptor"><propertyname="properties"><!--使用下面的方式配置参数,一行配置一个 --><value> helperDialect=mysql </value></property></bean></array></property></bean><!--4.动态生成Dao接口实现类--><beanclass="org.mybatis.spring.mapper.MapperScannerConfigurer"><!--注入sqlSessionFactory 注意其类型为String 只需要注入bean的名称就可以--><propertyname="sqlSessionFactoryBeanName"value="sqlSessionFactory"/><!--给出扫描的包,告诉他为谁生成--><propertyname="basePackage"value="com.hqyj.psl.mapper"/></bean></beans> 复制代码 spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--开启包扫描--><context:component-scanbase-package="com.hqyj.psl.controller"/><!--2.配置注解驱动--><mvc:annotation-driven><!--json乱码问题--><mvc:message-convertersregister-defaults="true"><beanclass="org.springframework.http.converter.StringHttpMessageConverter"><constructor-argvalue="UTF-8"/></bean><beanclass="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"><propertyname="objectMapper"><beanclass="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"><propertyname="failOnEmptyBeans"value="false"/></bean></property></bean></mvc:message-converters></mvc:annotation-driven><!--3配置静态资源--><mvc:resourcesmapping="/static/**"location="/static/"/><mvc:resourcesmapping="/upload/**"location="/upload/"/><!--4.静态资源的servlet配置 --><mvc:default-servlet-handler/><!--5.配置视图解析器--><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="prefix"value="/WEB-INF/jsp/"/><propertyname="suffix"value=".jsp"/></bean><!--6.配置文档上传下载配置 ,假设没有使用文件可以不用配置,同时也不用引入pomjar--><beanid="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><!--编码--><propertyname="defaultEncoding"value="utf-8"/><propertyname="maxUploadSize"value="10480000000"/><propertyname="maxInMemorySize"value="40960"/></bean></beans> 复制代码 spring-service.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><!--1.配置扫描包--><context:component-scanbase-package="com.hqyj.psl.service"/><!-- <!–2.配置事务对象–>--><!-- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">--><!-- <property name="dataSource" ref="dataSource"/>--><!-- </bean>--><!--3.开启事务注解支持--><!-- <tx:annotation-driven transaction-manager="transactionManager"/>--><!--4.事务的第二种方式 --><!-- <tx:advice id="accountTransaction" transaction-manager="transactionManager">--><!-- <tx:attributes>--><!-- <tx:method name="changeMoney" isolation="DEFAULT" propagation="REQUIRED" rollback-for="java.lang.RuntimeException"/>--><!-- <tx:method name="change*"/>--><!-- <!–可以写多个方法--><!-- 1.直接写方法名--><!-- 2.通配符:select *--><!-- –>--><!-- </tx:attributes>--><!-- </tx:advice>--><!-- --></beans> 复制代码 spring-shiro.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"><!--0.密码匹配器--><beanid="passwordMatcher"class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"><!--设置加密方式--><propertyname="hashAlgorithmName"value="MD5"/><!--加密次数--><propertyname="hashIterations"value="1024"/></bean><!--1.配置停止受权和认证的Realm--><beanid="myRealm"class="com.hqyj.psl.realm.UserRealm"><!--注入密码适配器--><!-- <property name="credentialsMatcher" ref="passwordMatcher"/>--></bean><!--2.配置SecurityManage--><beanid="securityManage"class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"><!--设置Realm--><propertyname="realm"ref="myRealm"/></bean><!--3.配置shiroFilter,必需和web.xml中的file-name一致,拦截恳求资源--><beanid="shiroFilter"class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"><propertyname="securityManager"ref="securityManage"/><!--假设非法访问时,设置默认跳转的资源的url 跳转回登录页面--><propertyname="loginUrl"value="/login"/><!--无权访问跳转页面--><propertyname="unauthorizedUrl"value="/noPower"/><!--配置拦截--><propertyname="filterChainDefinitions"><value><!-- 身份: anno 匿名访问 authc 认证后才干访问 roles[角色名] 注意!!!:roles[角色1,角色2],表示满足两个角色的用户才干访问 perms[权限名] 拥有某个权限的用户 --> /login=anon /index=authc /admin-role=roles[admin] <!-- /users/userList=roles[simple,admin]--> /users/delete=perms[delete]<!--zhangsan不能访问--> /users/deleteAll=perms[delete]<!--zhangsan不能访问--> /users/renew=perms[update] /users/phyDel=perms[delete] /users/renewAll=perms[update] /orders/deleteAll=perms[delete] /orders/delete=perms[delete] /myFileAjax/deleteFile=perms[delete] </value></property></bean></beans> 复制代码 三、后端功能实现
1.实体层(entity)
Admin.javapackagecom.hqyj.psl.entity;importlombok.AllArgsConstructor;importlombok.Data;importlombok.NoArgsConstructor;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/18 * \* Time: 22:20 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@Data@AllArgsConstructor@NoArgsConstructorpublicclassAdmin{privateInteger adminId;privateString sex;privateString name;privateString phone;privateString email;privateString remark;privateString username;privateString password;} 复制代码 AdminVo.javapackagecom.hqyj.psl.entity;importlombok.Data;importjava.util.List;@DatapublicclassAdminVoextendsAdmin{privateInteger adminId;privateString username;privateList<Role> roles;privateInteger roleId;privateString rname;privateString url;// private List<Permission> permissions;} 复制代码 MyFile.javapackagecom.hqyj.psl.entity;importlombok.Data;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/17 * \* Time: 14:06 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@DatapublicclassMyFile{privateInteger fileId;privateString fileName;privateString fileUrl;//存储的是Tomcat中的war包中的地址} 复制代码 Orders.javapackagecom.hqyj.psl.entity;importcom.fasterxml.jackson.annotation.JsonFormat;importorg.springframework.format.annotation.DateTimeFormat;importjava.util.Date;publicclassOrdersextendsUsersPage{privateInteger ordersId;privateString ordersNo;privateString ordersName;privateString phone;privateDouble totalAmount;privateDouble payAmount;privateString ordersState;privateString payState;privateString shipmentsState;privateString giveMethod;@DateTimeFormat(pattern ="yyyy-MM-dd")privateDate ordersTime;privateInteger isVip;privateString listId;publicStringgetListId(){return listId;}publicvoidsetListId(String listId){this.listId = listId;}publicIntegergetIsVip(){return isVip;}publicvoidsetIsVip(Integer isVip){this.isVip = isVip;}@OverridepublicStringtoString(){return"Orders{"+"ordersId="+ ordersId +", ordersNo='"+ ordersNo +'\''+", ordersName='"+ ordersName +'\''+", phone='"+ phone +'\''+", totalAmount="+ totalAmount +", payAmount="+ payAmount +", ordersState='"+ ordersState +'\''+", payState='"+ payState +'\''+", shipmentsState='"+ shipmentsState +'\''+", giveMethod='"+ giveMethod +'\''+", ordersTime="+ ordersTime +", isVip="+ isVip +", listId="+ listId +'}';}publicIntegergetOrdersId(){return ordersId;}publicvoidsetOrdersId(Integer ordersId){this.ordersId = ordersId;}publicStringgetOrdersNo(){return ordersNo;}publicvoidsetOrdersNo(String ordersNo){this.ordersNo = ordersNo;}publicStringgetOrdersName(){return ordersName;}publicvoidsetOrdersName(String ordersName){this.ordersName = ordersName;}publicStringgetPhone(){return phone;}publicvoidsetPhone(String phone){this.phone = phone;}publicDoublegetTotalAmount(){return totalAmount;}publicvoidsetTotalAmount(Double totalAmount){this.totalAmount = totalAmount;}publicDoublegetPayAmount(){return payAmount;}publicvoidsetPayAmount(Double payAmount){this.payAmount = payAmount;}publicStringgetOrdersState(){return ordersState;}publicvoidsetOrdersState(String ordersState){this.ordersState = ordersState;}publicStringgetPayState(){return payState;}publicvoidsetPayState(String payState){this.payState = payState;}publicStringgetShipmentsState(){return shipmentsState;}publicvoidsetShipmentsState(String shipmentsState){this.shipmentsState = shipmentsState;}publicStringgetGiveMethod(){return giveMethod;}publicvoidsetGiveMethod(String giveMethod){this.giveMethod = giveMethod;}@JsonFormat(pattern ="yyyy-MM-dd")publicDategetOrdersTime(){return ordersTime;}publicvoidsetOrdersTime(Date ordersTime){this.ordersTime = ordersTime;}} 复制代码 Permission.javapackagecom.hqyj.psl.entity;importlombok.AllArgsConstructor;importlombok.Data;importlombok.NoArgsConstructor;@Data@AllArgsConstructor@NoArgsConstructorpublicclassPermission{privateInteger permissionId;privateString url="sdfasdf";privateString state;} 复制代码 Role.javapackagecom.hqyj.psl.entity;importlombok.Data;@DatapublicclassRole{privateInteger roleId;privateString name;privateString state;} 复制代码 Users.javapackagecom.hqyj.psl.entity;importcom.fasterxml.jackson.annotation.JsonFormat;importorg.springframework.format.annotation.DateTimeFormat;importjava.util.Date;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/19 * \* Time: 13:52 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */publicclassUsersextendsUsersPage{privateInteger usersId;privateString name;//昵称privateString sex;privateString address;privateString phone;privateString email;privateString username;privateString password;privateInteger isVip;privateInteger deleted;//做逻辑删除的privateString bitId;privateString rbitId;publicStringgetRbitId(){return rbitId;}publicvoidsetRbitId(String rbitId){this.rbitId = rbitId;}publicStringgetBitId(){return bitId;}publicvoidsetBitId(String bitId){this.bitId = bitId;}@DateTimeFormat(pattern ="yyyy-MM-dd")privateDate joinDate;//入职日期@OverridepublicStringtoString(){return"Users{"+"usersId="+ usersId +", name='"+ name +'\''+", sex='"+ sex +'\''+", address='"+ address +'\''+", phone='"+ phone +'\''+", email='"+ email +'\''+", username='"+ username +'\''+", password='"+ password +'\''+", isVip="+ isVip +", deleted="+ deleted +", joinDate="+ joinDate +'}';}publicIntegergetUsersId(){return usersId;}publicvoidsetUsersId(Integer usersId){this.usersId = usersId;}publicStringgetName(){return name;}publicvoidsetName(String name){this.name = name;}publicStringgetSex(){return sex;}publicvoidsetSex(String sex){this.sex = sex;}publicStringgetAddress(){return address;}publicvoidsetAddress(String address){this.address = address;}publicStringgetPhone(){return phone;}publicvoidsetPhone(String phone){this.phone = phone;}publicStringgetEmail(){return email;}publicvoidsetEmail(String email){this.email = email;}publicStringgetUsername(){return username;}publicvoidsetUsername(String username){this.username = username;}publicStringgetPassword(){return password;}publicvoidsetPassword(String password){this.password = password;}publicIntegergetIsVip(){return isVip;}publicvoidsetIsVip(Integer isVip){this.isVip = isVip;}publicIntegergetDeleted(){return deleted;}publicvoidsetDeleted(Integer deleted){this.deleted = deleted;}@JsonFormat(pattern ="yyyy-MM-dd")publicDategetJoinDate(){return joinDate;}publicvoidsetJoinDate(Date joinDate){this.joinDate = joinDate;}} 复制代码 UsersPage.javapackagecom.hqyj.psl.entity;importlombok.Data;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/16 * \* Time: 14:07 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@DatapublicclassUsersPage{privateInteger page;//页数privateInteger num;//每页数量} 复制代码 2.耐久层(mapper)又称dao层
AdminMapper.javapackagecom.hqyj.psl.mapper;importcom.hqyj.psl.entity.Admin;importorg.springframework.stereotype.Repository;importjava.util.List;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/18 * \* Time: 23:13 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@RepositorypublicinterfaceAdminMapper{AdminselectByName(String username);IntegerinsertBySignup(String username,String password);Integerupdate(Admin admin);Adminshow(Admin admin);//根据用户名查询所拥有的角色List<String>selectRolesByUsername(String name);//根据用户名查询拥有的权限List<String>selectPermsByUsername(String name);} 复制代码 MyFileMapper.javapackagecom.hqyj.psl.mapper;importcom.hqyj.psl.entity.MyFile;importorg.springframework.stereotype.Repository;importjava.util.List;@RepositorypublicinterfaceMyFileMapper{//查所有List<MyFile>selectAll();//添加Integerinsert(MyFile myFile);//删除//修改//根据id查询//移除文件IntegerdeleteFile(MyFile myFile);} 复制代码 OrdersMapper.javapackagecom.hqyj.psl.mapper;importcom.hqyj.psl.entity.Orders;importorg.springframework.stereotype.Repository;importjava.util.List;@RepositorypublicinterfaceOrdersMapper{/*List<Orders> selectAll();*///删除Integerdelete(Orders orders);//修改Integerupdate(Orders orders);//修改Integerinsert(Orders orders);//模糊查/查所有List<Orders>selectLike(Orders orders);IntegerdeleteAll(List list);} 复制代码 RoleMapper.javapackagecom.hqyj.psl.mapper;importcom.hqyj.psl.entity.AdminVo;importcom.hqyj.psl.entity.Role;importorg.springframework.stereotype.Repository;importjava.util.List;@RepositorypublicinterfaceRoleMapper{//查找所有角色List<AdminVo>selectRoleAll();//根据角色查询所有拥有权限List<String>selectPermsByRole(Integer roleId);//根据用户名查询所有拥有的角色List<String>selectRolesByUsername(String username);//根据用户名查询所有拥有的权限List<String>selectPermsByUsername(String username);//添加角色及其权限//修改角色与权限//直接修改role表修改角色名IntegerupdateRoleName(Role role);//修改权限//删除权限关联表中的关联IntegerdeleteRole_P(Integer roleId);//根据权限名url查询权限idIntegerselectPreId(String url);//添加权限关联表中的关联添加 preidIntegeraddRole_P(Integer rId,Integer pId);//删除逻辑//1.删除Role表中的关系IntegerdeleteRole(Integer roleId);//2.删除Role_Pre中的关系//上面有方法//添加角色逻辑//1.在Role表中添加角色名IntegeraddRoleName(Role role);//2.查询Role表中的roleId 通过角色名IntegerselectRoleByName(Role role);//3.根据权限名url查询权限id//修改里面有方法//4.添加权限关联表中的关联添加 preid//修改里面有方法} 复制代码 UsersMapper.javapackagecom.hqyj.psl.mapper;importcom.hqyj.psl.entity.Users;importcom.hqyj.psl.entity.Users;importorg.springframework.stereotype.Repository;importjava.util.List;@RepositorypublicinterfaceUsersMapper{//查所有List<Users>selectAll();//添加Integerinsert(Users users);//删除IntegerdeleteByUserId(Integer id);//修改Integerupdate(Users users);//逻辑删除IntegerdeleteUpdByUserId(Integer usersId);List<Users>search(Users users);IntegerdeleteAll(List list);//查找逻辑删除的List<Users>selectByDeletedUsers();//恢复删除Integerrenew(Integer usersId);//物理删除IntegerphyDel(Integer usersId);//条件查找List<Users>condQuery(Users user);//批量恢复IntegerupdateRenbit(List list);/*登录*/UsersselectOneByUsername(String username);//// //根据用户名查询所拥有的角色// List<String> selectRolesByUsername(String username);// //根据用户名查询拥有的权限// List<String> selectPermsByUsername(String username);} 复制代码 3.业务层(service)
service(定义接口)
AdminService.javapackagecom.hqyj.psl.service;importcom.hqyj.psl.entity.Admin;importcom.hqyj.psl.entity.AdminVo;importcom.hqyj.psl.utils.ResultUtils;importjavax.servlet.http.HttpSession;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/19 * \* Time: 14:06 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */publicinterfaceAdminService{ResultUtilslogin(Admin admin,HttpSession session);ResultUtilsregister(Admin admin);ResultUtilslogout(HttpSession session);ResultUtilsupdate(Admin admin);ResultUtilsshow(Admin admin);} 复制代码 MyFileService.javapackagecom.hqyj.psl.service;importcom.hqyj.psl.entity.MyFile;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.http.ResponseEntity;importorg.springframework.web.multipart.MultipartFile;importjavax.servlet.http.HttpServletRequest;importjava.io.IOException;publicinterfaceMyFileService{//查所有ResultUtilsfileList();//增加ResultUtilsinsert(MyFile myFile);//文档的上传 MultipartFile.transferTo 将接受到的文件传输到给定的目的文件ResultUtilsupload(MultipartFile multipartFile,HttpServletRequest request);//文档的下载ResponseEntity<byte[]>downLoad(String fileName,HttpServletRequest request)throwsIOException;//文档移除ResultUtilsdeleteFile(MyFile myFile);} 复制代码 OrdersService.javapackagecom.hqyj.psl.service;importcom.hqyj.psl.entity.Orders;importcom.hqyj.psl.utils.ResultUtils;publicinterfaceOrdersService{/*ResultUtils ordersList(Orders orders);//查所有*/ResultUtilsdelete(Orders orders);//删除ResultUtilsupdate(Orders orders);//修改ResultUtilsinsert(Orders orders);//增加ResultUtilsselectLike(Orders orders);//模糊查/查所有ResultUtilsdeleteAll(Orders orders);//批量删除} 复制代码 UsersService.javapackagecom.hqyj.psl.service;importcom.hqyj.psl.entity.Users;importcom.hqyj.psl.utils.ResultUtils;importjavax.servlet.http.HttpSession;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/19 * \* Time: 14:00 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */publicinterfaceUsersService{ResultUtilsusersList(Users user);ResultUtilslogin(Users user,HttpSession session);ResultUtilslogout(HttpSession session);ResultUtilsupdate(Users user);ResultUtilsdeleteUpdByUserId(Users user);ResultUtilsdelete(Integer id);ResultUtils insert (Users user);ResultUtilssearch(Users users);ResultUtilsdeleteAll(Users users);ResultUtilsselectByDeletedUsers(Users user);//查找被逻辑删除的ResultUtilsrenew(Users user);//恢复删除ResultUtilsphyDel(Users user);//物理删除ResultUtilscondQuery(Users user);//条件查找ResultUtilsrenewAll(Users user);//批量恢复} 复制代码 Impl(实现接口)
AdminServiceImpl.javapackagecom.hqyj.psl.service.impl;importcom.hqyj.psl.entity.Admin;importcom.hqyj.psl.entity.AdminVo;importcom.hqyj.psl.mapper.AdminMapper;importcom.hqyj.psl.service.AdminService;importcom.hqyj.psl.utils.ResultUtils;importorg.apache.shiro.SecurityUtils;importorg.apache.shiro.authc.IncorrectCredentialsException;importorg.apache.shiro.authc.UnknownAccountException;importorg.apache.shiro.authc.UsernamePasswordToken;importorg.apache.shiro.subject.Subject;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Service;importjavax.servlet.http.HttpSession;importjava.util.List;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/19 * \* Time: 14:06 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@ServicepublicclassAdminServiceImplimplementsAdminService{@AutowiredprivateAdminMapper adminMapper;@OverridepublicResultUtilslogin(Admin admin,HttpSession session){//0.非空验证if(admin.getUsername()==""|| admin.getPassword()==""){returnnewResultUtils(500,"用户名不能为空",null);}try{//1.获取当前用户对象主体Subject subject =SecurityUtils.getSubject();System.out.println("service中的subject对象:"+ subject);//2.将恳求参数封装到token中UsernamePasswordToken token =newUsernamePasswordToken(admin.getUsername(), admin.getPassword());//3。完成登录 subject.login(token); session.setAttribute("user",admin.getUsername()); session.setAttribute("admin",admin);returnnewResultUtils(200,"登录胜利",null);}catch(UnknownAccountException e){returnnewResultUtils(500,"用户名不存在",null);}catch(IncorrectCredentialsException e){returnnewResultUtils(500,"密码错误",null);}}@OverridepublicResultUtilsregister(Admin admin){Integer integer = adminMapper.insertBySignup(admin.getUsername(),admin.getPassword());returnnewResultUtils(200,"注册胜利","success");}@OverridepublicResultUtilslogout(HttpSession session){//退出(session失效)//基于登录状态下放入session中所有的属性,如用户信息(状态),购物车等 session.invalidate();//session移除某一个属性//session.removeAttribute("user");returnnewResultUtils(200,"退出胜利","login");}//修改用户个人信息@OverridepublicResultUtilsupdate(Admin admin){System.out.println("修改里面的数据"+admin);Integer update = adminMapper.update(admin);returnnewResultUtils(200,"修改胜利","");}//数据回显@OverridepublicResultUtilsshow(Admin admin){Admin show = adminMapper.show(admin);returnnewResultUtils(200,"显示胜利",show);}} 复制代码 MyFileServiceImpl.javapackagecom.hqyj.psl.service.impl;importcom.hqyj.psl.entity.MyFile;importcom.hqyj.psl.mapper.MyFileMapper;importcom.hqyj.psl.service.MyFileService;importcom.hqyj.psl.utils.ResultUtils;importorg.apache.commons.io.FileUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.http.HttpHeaders;importorg.springframework.http.HttpStatus;importorg.springframework.http.MediaType;importorg.springframework.http.ResponseEntity;importorg.springframework.stereotype.Service;importorg.springframework.web.multipart.MultipartFile;importjavax.servlet.http.HttpServletRequest;importjava.io.File;importjava.io.IOException;importjava.util.HashMap;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/17 * \* Time: 14:25 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@ServicepublicclassMyFileServiceImplimplementsMyFileService{@AutowiredprivateMyFileMapper myFileMapper;@OverridepublicResultUtilsfileList(){returnnewResultUtils(200,"",myFileMapper.selectAll());}@OverridepublicResultUtilsinsert(MyFile myFile){ myFileMapper.insert(myFile);returnnewResultUtils(200,"添加胜利",null);}@OverridepublicResultUtilsupload(MultipartFile multipartFile,HttpServletRequest request){try{//1.获取文件上传目录的途径String filePath= request.getSession().getServletContext().getRealPath("upload");//虚拟途径System.out.println("上传文件的目录途径"+filePath);//2.获取上传的文件名String fileName = multipartFile.getOriginalFilename();System.out.println("上传的文件名"+fileName);//3.创建File对象File f =newFile(filePath+"/"+fileName);//4.判断文件上传的目录是否存在if(!f.isDirectory()){//创建目录System.out.println("文件上传目录是否存在"); f.mkdirs();}//5.上传文件 multipartFile.transferTo(f);//6.创建map封装记录文件名及文件途径HashMap<String,Object> map =newHashMap<>();//localhost:8080/upload/a.txt map.put("servicePath","/upload/"+fileName); map.put("fileName",fileName);returnnewResultUtils(200,"上传胜利",map);}catch(IOException e){ e.printStackTrace();returnnewResultUtils(500,"上传失败",null);}}@OverridepublicResponseEntity<byte[]>downLoad(String fileName,HttpServletRequest request)throwsIOException{//1.获取文档上传的途径String filePath = request.getSession().getServletContext().getRealPath("upload");System.out.println("获取文件上传的途径"+filePath);//2.创建文件对象File file =newFile(filePath +"/"+ fileName);//3.设置httpHeaders,使阅读器响应下载HttpHeaders headers =newHttpHeaders();//4.设置响应方式 headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);//5.设置响应头/* * headerName: * contentType:响应的内容格式 * contentDisposition * -inline:直接在页面展示a * -attachment:以附件的形式下载 * * 乱码处置: * */ headers.set("Content-Disposition","attachment;fileName="+newString(fileName.getBytes("utf-8"),"ISO8859-1")+"");returnnewResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers,HttpStatus.CREATED);}//移除文件@OverridepublicResultUtilsdeleteFile(MyFile myFile){Integer integer = myFileMapper.deleteFile(myFile);returnnewResultUtils(200,"移除胜利",null);}} 复制代码 OrderServiceImpl.javapackagecom.hqyj.psl.service.impl;importcom.github.pagehelper.PageHelper;importcom.github.pagehelper.PageInfo;importcom.hqyj.psl.entity.Orders;importcom.hqyj.psl.mapper.OrdersMapper;importcom.hqyj.psl.service.OrdersService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Service;importjava.util.Arrays;importjava.util.Date;importjava.util.HashMap;importjava.util.List;@ServicepublicclassOrderServiceImplimplementsOrdersService{@AutowiredprivateOrdersMapper ordersMapper;/*@Override public ResultUtils ordersList(Orders orders) { //开启分页 PageHelper.startPage(orders.getPage(),orders.getNum()); List<Orders> orders1 = ordersMapper.selectAll(); System.out.println(orders1+"-----------"); PageInfo list = new PageInfo(orders1); HashMap<String, Object> map = new HashMap<>(); map.put("totalPage",list.getPages());//总页数 map.put("list",list.getList());//每页的数据 map.put("total",list.getTotal());//总条数 return new ResultUtils(200,"",map); }*/@OverridepublicResultUtilsdelete(Orders orders){ ordersMapper.delete(orders);returnnewResultUtils(200,"删除胜利",null);}@OverridepublicResultUtilsupdate(Orders orders){ ordersMapper.update(orders);returnnewResultUtils(200,"修改胜利",null);}@OverridepublicResultUtilsinsert(Orders orders){ orders.setOrdersTime(newDate()); ordersMapper.insert(orders);returnnewResultUtils(200,"添加胜利",null);}@Override//模糊查/查所有publicResultUtilsselectLike(Orders orders){System.out.println(orders);//开启分页PageHelper.startPage(orders.getPage(),orders.getNum());List<Orders> order = ordersMapper.selectLike(orders);PageInfo list =newPageInfo(order);HashMap<String,Object> map =newHashMap<>(); map.put("totalPage",list.getPages());//总页数 map.put("list",list.getList());//每页的数据 map.put("total",list.getTotal());//总条数returnnewResultUtils(200,"找到"+order.size()+"条数据",map);}@OverridepublicResultUtilsdeleteAll(Orders orders){String[] split = orders.getListId().split(",");List<String> strings =Arrays.asList(split);Integer integer = ordersMapper.deleteAll(strings);if(integer >0)returnnewResultUtils(200,"删除胜利",null);returnnull;}} 复制代码 RoleServiceImpl.javapackagecom.hqyj.psl.service.impl;importcom.hqyj.psl.entity.AdminVo;importcom.hqyj.psl.entity.Role;importcom.hqyj.psl.mapper.RoleMapper;importcom.hqyj.psl.service.RoleService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Service;importjava.util.List;@ServicepublicclassRoleServiceImplimplementsRoleService{@AutowiredprivateRoleMapper roleMapper;@OverridepublicResultUtilsselectRolePerAll(){// //测试获取所有角色// List<AdminVo> strings = adminMapper.selectRoleAll();// //根据角色拿去对应权限// HashMap<String, List<String>> map = new HashMap<>();// for (int i = 0; i < strings.size(); i++) {// AdminVo adminVo = strings.get(i);// String username =adminVo.getUsername();// Integer adminId = adminVo.getAdminId();// List<String> url = adminMapper.selectPermsByRole(username);// url.add(adminId.toString());// map.put(username,url);// }// System.out.println("数据已经拿到了:"+map);//测试获取所有角色List<AdminVo> strings = roleMapper.selectRoleAll();//根据角色拿去对应权限System.out.println(strings);// HashMap<String, List<String>> map = new HashMap<>();for(int i =0; i < strings.size(); i++){AdminVo adminVo = strings.get(i);String username =adminVo.getUsername();Integer roleId = adminVo.getRoles().get(0).getRoleId();List<String> url = roleMapper.selectPermsByRole(roleId); strings.get(i).setUrl(url.toString());// map.put(username,url);}System.out.println(strings);returnnewResultUtils(200,"获取胜利",strings);}@OverridepublicResultUtilsupdateRoleAndPer(AdminVo adminVo){try{//直接修改role表修改角色名Role role =newRole(); role.setRoleId(adminVo.getRoleId()); role.setName(adminVo.getRname()); roleMapper.updateRoleName(role);//修改权限//删除权限关联表中的关联 roleMapper.deleteRole_P(role.getRoleId());//根据权限名url查询权限idString[] split = adminVo.getUrl().split(" ");System.out.println("我是权限:"+ split);for(int i =0; i < split.length; i++){if(!(split[i].equals(""))){System.out.println("我是权限......+"+split[i]);Integer preId = roleMapper.selectPreId(split[i]);System.out.println("我是preId....."+preId);//添加权限关联表中的关联添加 preid roleMapper.addRole_P(role.getRoleId(), preId);}}returnnewResultUtils(200,"修改胜利",null);}catch(Exception e){returnnewResultUtils(500,"修改失败",null);}}//删除Role@OverridepublicResultUtilsdeleteRole(AdminVo adminVo){try{//删除Role_pre中的关系 roleMapper.deleteRole_P(adminVo.getRoleId());//删除Role中角色 roleMapper.deleteRole(adminVo.getRoleId());returnnewResultUtils(200,"删除胜利",null);}catch(Exception e){returnnewResultUtils(500,"删除失败",null);}}//添加逻辑@OverridepublicResultUtilsaddRole(AdminVo adminVo){try{Role role =newRole(); role.setName(adminVo.getRname());//添加角色逻辑//1.在Role表中添加角色名 roleMapper.addRoleName(role);//2.查询Role表中的roleId 通过角色名Integer roleId = roleMapper.selectRoleByName(role); role.setRoleId(roleId);//3.根据权限名url查询权限idString[] split = adminVo.getUrl().split(" ");System.out.println("我是权限:"+ split);for(int i =0; i < split.length; i++){if(!(split[i].equals(""))){Integer preId = roleMapper.selectPreId(split[i]);//添加权限关联表中的关联添加 preid roleMapper.addRole_P(role.getRoleId(), preId);}}returnnewResultUtils(200,"添加胜利",null);}catch(Exception e){returnnewResultUtils(500,"添加失败",null);}}} 复制代码 UsersServiceImpl.javapackagecom.hqyj.psl.service.impl;importcom.github.pagehelper.PageHelper;importcom.github.pagehelper.PageInfo;importcom.hqyj.psl.entity.Users;importcom.hqyj.psl.mapper.UsersMapper;importcom.hqyj.psl.service.UsersService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Service;importjavax.servlet.http.HttpSession;importjava.util.Arrays;importjava.util.Date;importjava.util.HashMap;importjava.util.List;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/19 * \* Time: 14:01 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@ServicepublicclassUsersServiceImplimplementsUsersService{@AutowiredprivateUsersMapper usersMapper;@OverridepublicResultUtilssearch(Users users){PageHelper.startPage(users.getPage(),users.getNum());List<Users> search = usersMapper.search(users);PageInfo pageInfo =newPageInfo(search);HashMap<String,Object> hashMap =newHashMap<>(); hashMap.put("totalPage",pageInfo.getPages()); hashMap.put("list",pageInfo.getList()); hashMap.put("total",pageInfo.getTotal());returnnewResultUtils(200,"模糊查询分页",hashMap);}@OverridepublicResultUtilsdeleteAll(Users users){//处置字符串String[] strings = users.getBitId().split(",");//将字符数组转为listList<String> list =Arrays.asList(strings);System.out.println(list); usersMapper.deleteAll(list);returnnewResultUtils(200,"删除胜利",null);}@OverridepublicResultUtilsusersList(Users users){//开启分页PageHelper.startPage(users.getPage(),users.getNum());//获取所有数据List<Users> userAll = usersMapper.selectAll();System.out.println("分页");PageInfo list =newPageInfo(userAll);HashMap<String,Object> map =newHashMap<>(); map.put("totalPage",list.getPages());//总页数 map.put("list",list.getList());//每页显示的数据 map.put("total",list.getTotal());//总条数returnnewResultUtils(200,"",map);}@OverridepublicResultUtilslogin(Users users,HttpSession session){returnnull;}@OverridepublicResultUtilslogout(HttpSession session){returnnull;}@OverridepublicResultUtilsupdate(Users users){ users.setDeleted(0);System.out.println("跑了"); users.setJoinDate(newDate());Integer update = usersMapper.update(users);if(update>0){returnnewResultUtils(200,"修改胜利",null);}else{returnnewResultUtils(500,"修改失败",null);}}@OverridepublicResultUtilsdeleteUpdByUserId(Users users){ usersMapper.deleteUpdByUserId(users.getUsersId());returnnewResultUtils(200,"删除胜利",null);}@OverridepublicResultUtilsdelete(Integer id){returnnull;}@OverridepublicResultUtilsinsert(Users users){System.out.println(users); users.setDeleted(0); users.setJoinDate(newDate()); usersMapper.insert(users);returnnewResultUtils(200,"已添加",null);}@OverridepublicResultUtilsselectByDeletedUsers(Users user){System.out.println("当前页:"+ user.getPage());System.out.println("当前页条数:"+ user.getNum());//开启分页PageHelper.startPage(user.getPage(),user.getNum());//PageHelper.startPage(1,2);//获取所有数据List<Users> users = usersMapper.selectByDeletedUsers();PageInfo list =newPageInfo(users);HashMap<String,Object> map =newHashMap<>(); map.put("totalPage",list.getPages());//总页数 map.put("list",list.getList());//每页显示的数据 map.put("total",list.getTotal());//总条数returnnewResultUtils(200,"",map);}//恢复删除@OverridepublicResultUtilsrenew(Users user){ usersMapper.renew(user.getUsersId());returnnewResultUtils(200,"恢复胜利",null);}@OverridepublicResultUtilsphyDel(Users user){ usersMapper.phyDel(user.getUsersId());returnnewResultUtils(200,"删除胜利",null);}//查找全部被逻辑删除的@OverridepublicResultUtilscondQuery(Users user){System.out.println("当前页:"+ user.getPage());System.out.println("当前页条数:"+ user.getNum());//开启分页PageHelper.startPage(user.getPage(), user.getNum());//PageHelper.startPage(1,2);//获取所有数据List<Users> users = usersMapper.condQuery(user);PageInfo list =newPageInfo(users);HashMap<String,Object> map =newHashMap<>(); map.put("totalPage", list.getPages());//总页数 map.put("list", list.getList());//每页显示的数据 map.put("total", list.getTotal());//总条数returnnewResultUtils(200,"查找胜利", map);}//批量恢复@OverridepublicResultUtilsrenewAll(Users users){//1.处置字符串String[] strings = users.getRbitId().split(",");//2.将字符转为listList<String> list =Arrays.asList(strings);System.out.println("id为:"+list);//3. usersMapper.updateRenbit(list);returnnewResultUtils(200,"恢复胜利",null);}} 复制代码 4.控制层(controller)
AdminController.javapackagecom.hqyj.psl.controller;importcom.hqyj.psl.entity.AdminVo;importcom.hqyj.psl.service.RoleService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RestController;@RestControllerpublicclassAdminController{@AutowiredprivateRoleService roleService;//前端角色逻辑@RequestMapping("/adminRole/{url}")publicResultUtilsadminRole(@PathVariableString url,AdminVo adminVo){System.out.println("前端发送的数据为:"+url);switch(url){case"role":return roleService.selectRolePerAll();case"updateRole":return roleService.updateRoleAndPer(adminVo);case"deleteRole":return roleService.deleteRole(adminVo);case"addRole":return roleService.addRole(adminVo);// return adminService.addRole(adminVo);}returnnull;}} 复制代码 FileController.javapackagecom.hqyj.psl.controller;importcom.hqyj.psl.entity.MyFile;importcom.hqyj.psl.service.MyFileService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.http.ResponseEntity;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RequestParam;importorg.springframework.web.bind.annotation.RestController;importorg.springframework.web.multipart.MultipartFile;importjavax.servlet.http.HttpServletRequest;importjava.io.IOException;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/17 * \* Time: 15:00 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@RestControllerpublicclassFileController{@AutowiredprivateMyFileService myFileService;//执行file的增删查改恳求@RequestMapping("/myFileAjax/{url}")publicResultUtilsmyFileAjax(@PathVariableString url,MyFile myFile){switch(url){case"insert":return myFileService.insert(myFile);case"fileList":return myFileService.fileList();case"deleteFile":return myFileService.deleteFile(myFile);}returnnull;}//文档上传恳求@RequestMapping("/file/upload")publicResultUtilsupload(@RequestParam("file")MultipartFile file,HttpServletRequest request){return myFileService.upload(file,request);}//文件下载@RequestMapping("/file/downLoad")publicResponseEntity<byte[]>downLoad(String fileName,HttpServletRequest request)throwsIOException{return myFileService.downLoad(fileName,request);}} 复制代码 packagecom.hqyj.psl.controller;importcom.hqyj.psl.entity.Orders;importcom.hqyj.psl.service.OrdersService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RestController;@RestControllerpublicclassOrdersController{@AutowiredprivateOrdersService ordersService;@RequestMapping("/orders/{url}")publicResultUtilstoOrders(@PathVariableString url,Orders orders){switch(url){/*case "ordersList"://查所有 return ordersService.ordersList(orders);*/case"delete"://删除 return ordersService.delete(orders);case"update"://修改 return ordersService.update(orders);case"insert"://增加 return ordersService.insert(orders);case"selectLike"://模糊查 return ordersService.selectLike(orders);case"deleteAll"://模糊查 return ordersService.deleteAll(orders);}returnnull;}} 复制代码 OrdersController.javapackagecom.hqyj.psl.controller;importcom.hqyj.psl.entity.Orders;importcom.hqyj.psl.service.OrdersService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RestController;@RestControllerpublicclassOrdersController{@AutowiredprivateOrdersService ordersService;@RequestMapping("/orders/{url}")publicResultUtilstoOrders(@PathVariableString url,Orders orders){switch(url){/*case "ordersList"://查所有 return ordersService.ordersList(orders);*/case"delete"://删除 return ordersService.delete(orders);case"update"://修改 return ordersService.update(orders);case"insert"://增加 return ordersService.insert(orders);case"selectLike"://模糊查 return ordersService.selectLike(orders);case"deleteAll"://模糊查 return ordersService.deleteAll(orders);}returnnull;}} 复制代码 PageController.javapackagecom.hqyj.psl.controller;importorg.springframework.stereotype.Controller;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/15 * \* Time: 16:30 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@ControllerpublicclassPageController{@RequestMapping("/{url}")publicStringlogin(@PathVariableString url){return url;}} 复制代码 UsersController.javapackagecom.hqyj.psl.controller;importcom.hqyj.psl.entity.Admin;importcom.hqyj.psl.entity.Users;importcom.hqyj.psl.entity.Users;importcom.hqyj.psl.service.AdminService;importcom.hqyj.psl.service.UsersService;importcom.hqyj.psl.service.UsersService;importcom.hqyj.psl.utils.ResultUtils;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RestController;importjavax.servlet.http.HttpSession;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/12 * \* Time: 10:21 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@RestControllerpublicclassUsersController{@AutowiredprivateUsersService usersService;@AutowiredprivateAdminService adminService;@RequestMapping("/admin/{url}")publicResultUtilslogin(@PathVariableString url,Admin admin,HttpSession session){switch(url){case"login":return adminService.login(admin,session);case"signup":return adminService.register(admin);case"logout":return adminService.logout(session);case"update":return adminService.update(admin);case"showAdm":return adminService.show(admin);}returnnull;}@RequestMapping("/users/{url}")// @ResponseBodypublicResultUtilstoLogin(@PathVariableString url,Users users,HttpSession session){switch(url){case"login":return usersService.login(users,session);case"deleteAll":return usersService.deleteAll(users);case"search":return usersService.search(users);case"userList":return usersService.usersList(users);case"updateUsers":return usersService.update(users);case"deleteUserById":return usersService.delete(users.getUsersId());case"insertUser":return usersService.insert(users);case"delete":return usersService.deleteUpdByUserId(users);case"userDel":return usersService.selectByDeletedUsers(users);case"renew":return usersService.renew(users);case"phyDel":return usersService.phyDel(users);case"condQuery":System.out.println("1");return usersService.condQuery(users);case"renewAll":return usersService.renewAll(users);}returnnull;// 1.接受数据}} 复制代码 5.工具层(utils)
MdFiveUtils.javapackagecom.hqyj.psl.utils;importorg.apache.shiro.crypto.hash.Md5Hash;importorg.apache.shiro.crypto.hash.SimpleHash;importorg.springframework.stereotype.Component;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/20 * \* Time: 9:41 * \* To change this template use File | Settings | File Templates. * \* Description: * \ */@Component//注册beanpublicclassMdFiveUtils{publicStringchangePassword(String salt,String password){Md5Hash md5Hash =newMd5Hash(salt);SimpleHash pwd =newSimpleHash("MD5", password, md5Hash,1024);return pwd.toString();}publicstaticvoidmain(String[] args){MdFiveUtils md =newMdFiveUtils();String zhangsan = md.changePassword("zhangsan","123456");System.out.println(zhangsan);}} 复制代码 ResultUtils.javapackagecom.hqyj.psl.utils;importlombok.AllArgsConstructor;importlombok.Data;importlombok.NoArgsConstructor;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/16 * \* Time: 10:12 * \* To change this template use File | Settings | File Templates. * \* Description: * 结果集工具类 * \ */@Data@AllArgsConstructor@NoArgsConstructorpublicclassResultUtils{privateInteger code;//状态码privateString msg;//消息信息privateObject data;//返回对象} 复制代码 UserRealm.java
6.登录实现层(realm)
packagecom.hqyj.psl.realm;importcom.hqyj.psl.entity.Admin;importcom.hqyj.psl.mapper.AdminMapper;importorg.apache.shiro.authc.*;importorg.apache.shiro.authz.AuthorizationInfo;importorg.apache.shiro.authz.SimpleAuthorizationInfo;importorg.apache.shiro.crypto.hash.Md5Hash;importorg.apache.shiro.realm.AuthorizingRealm;importorg.apache.shiro.subject.PrincipalCollection;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.test.context.TestConstructor;importjava.util.List;/** * \* Created with IntelliJ IDEA. * \* User: PuSongLin * \* Date: 2022/8/18 * \* Time: 9:41 * \* To change this template use File | Settings | File Templates. * \* Description: 领域:用于帮我们认证添加当前主体(subject--用户)的角色信息,权限信息 * \ */publicclassUserRealmextendsAuthorizingRealm{@AutowiredprivateAdminMapper adminMapper;@Override//受权protectedAuthorizationInfodoGetAuthorizationInfo(PrincipalCollection principalCollection){//1.获取当前登录的用户String name = principalCollection.fromRealm(this.getName()).iterator().next()+"";System.out.println("获取当前登录的用户"+name);//2.根据用户名查询角色及权限信息List<String> roles = adminMapper.selectRolesByUsername(name);List<String> perms = adminMapper.selectPermsByUsername(name);System.out.println("角色为:"+roles+"权限为:"+perms);//3.获取受权信息对象SimpleAuthorizationInfo simpleAuthorizationInfo =newSimpleAuthorizationInfo();System.out.println("受权对象"+simpleAuthorizationInfo);//4.添加角色信息 simpleAuthorizationInfo.addRoles(roles);//5.添加受权信息 simpleAuthorizationInfo.addStringPermissions(perms);System.out.println("受权信息:"+simpleAuthorizationInfo);return simpleAuthorizationInfo;}@Override//认证-- 此处可究,量力而行protectedAuthenticationInfodoGetAuthenticationInfo(AuthenticationToken authenticationToken)throwsAuthenticationException{//1.取出token对象 authenticationTokenUsernamePasswordToken token=(UsernamePasswordToken)authenticationToken;System.out.println("token对象:"+token);//2.获取身份凭证String username = token.getPrincipal()+"";System.out.println("凭证为:"+username);//3.检验是否存在Admin admin =adminMapper.selectByName(username);//4.判断用户是否存在if(admin==null){thrownewUnknownAccountException();}// return new SimpleAuthenticationInfo(用户名,密码,盐值,realm名字);//new Md5Hash(admin.getUsername()),System.out.println("权限:"+admin.getUsername()+"密码:"+admin.getPassword()+"realm:"+this.getName());returnnewSimpleAuthenticationInfo(admin.getUsername(),admin.getPassword(),this.getName());}} 复制代码 四、前端功能实现
1.static(前端静态资源显示)
这里下载解压到webappp文件下面
链接:https://pan.baidu.com/s/1D_EFbLyAO_faeH6uVEQvJA?pwd=9uwv
提取码:9uwv
2.upoad(文件上传目录)
在webapp文件下创建一个upload文件用于贮存我们上传的文件。
3.jsp(显示页面格式为:xxx.jsp)
详细实现代码我这里就不写了
源代码就放在这里了。
链接:https://pan.baidu.com/s/1gS1p2XhJTyRY0vxCaBsYfQ?pwd=tzzk
提取码:tzzk
总结
提示:这里对文章停止总结:
有什么不懂,欢送各位评论留言
都看到这里了,请各位的发财小手手点个赞。谢谢!