本文档主要记录的是SSM框架集成Spring Security来做账户登录操作,已经集成了MyBatis,省略了基本的操作

实体User

首先需要先定义用户实体User的dto


public class User{@Id//标识主键@GeneratedValue(strategy = GenerationType.IDENTITY) //自增长策略private Long id;private String email;private String password;private String phone;private String nickName;private String state;private String imgUrl;private String enable;public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email == null ? null : email.trim();}public void setPassword(String password) {this.password = password == null ? null : password.trim();}public String getPassword() {return password;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone == null ? null : phone.trim();}public String getNickName() {return nickName;}public void setNickName(String nickName) {this.nickName = nickName == null ? null : nickName.trim();}public String getState() {return state;}public void setState(String state) {this.state = state == null ? null : state.trim();}public String getImgUrl() {return imgUrl;}public void setImgUrl(String imgUrl) {this.imgUrl = imgUrl == null ? null : imgUrl.trim();}public String getEnable() {return enable;}public void setEnable(String enable) {this.enable = enable == null ? null : enable.trim();}}

实现UserDetails的接口

框架需要UserDetails类型的实体,所以我们要将User实现UserDetails的接口,然后重写他的所有方法

账户信息需要包含角色信息,因此添加了一个Role属性

public class User implements UserDetails {@Id//标识主键@GeneratedValue(strategy = GenerationType.IDENTITY) //自增长策略private Long id;private String email;private String password;private String phone;private String nickName;private String state;private String imgUrl;private String enable;@Transientprotected List<Role> roles;public List<Role> getRoles() {return roles;}public void setRoles(List<Role> roles) {this.roles = roles;}public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email == null ? null : email.trim();}@Overridepublic Collection<? extends GrantedAuthority> getAuthorities() {if(roles == null || roles.size()<=0){return null;}List<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>();for(Role r:roles){authorities.add(new SimpleGrantedAuthority(r.getRoleValue()));}return authorities;}@Overridepublic String getPassword() {return password;}@Overridepublic String getUsername() {return email;}@Overridepublic boolean isAccountNonExpired() {return true;}@Overridepublic boolean isAccountNonLocked() {return true;}@Overridepublic boolean isCredentialsNonExpired() {return true;}@Overridepublic boolean isEnabled() {if(StringUtils.isNotBlank(state) && "1".equals(state) && StringUtils.isNotBlank(enable) && "1".equals(enable)){return true;}return false;}public void setPassword(String password) {this.password = password == null ? null : password.trim();}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone == null ? null : phone.trim();}public String getNickName() {return nickName;}public void setNickName(String nickName) {this.nickName = nickName == null ? null : nickName.trim();}public String getState() {return state;}public void setState(String state) {this.state = state == null ? null : state.trim();}public String getImgUrl() {return imgUrl;}public void setImgUrl(String imgUrl) {this.imgUrl = imgUrl == null ? null : imgUrl.trim();}public String getEnable() {return enable;}public void setEnable(String enable) {this.enable = enable == null ? null : enable.trim();}@Overridepublic boolean equals(Object obj) {if (obj instanceof User) {return getEmail().equals(((User)obj).getEmail())||getUsername().equals(((User)obj).getUsername());}return false;}@Overridepublic int hashCode() {return getUsername().hashCode();}@Overridepublic String toString() {return "User{" +"id=" + id +", email='" + email + '\'' +", password='" + password + '\'' +", phone='" + phone + '\'' +", nickName='" + nickName + '\'' +", state='" + state + '\'' +", imgUrl='" + imgUrl + '\'' +", enable='" + enable + '\'' +", roles=" + roles +'}';}
}
public SimpleGrantedAuthority(String role) {Assert.hasText(role, "A granted authority textual representation is required");this.role = role;
}

SimpleGrantedAuthority的构造方法是String类型,

getAuthorities 方法是获取用户角色信息的方法,用于授权。不同的角色可以拥有不同的权限。

为了区分是否是同一个用户,重写 equals 和 hashCode 方法。

重写toString是为了输出信息

实现 UserDetailsService 接口

Spring Security 提供的获取用户信息的方式不满足我们的需求,所以我们自己制定获取用户信息的方式

我们不止是获取用户信息还需要获取角色信息

定义Role的实体类


public class Role {@Id//标识主键@GeneratedValue(strategy = GenerationType.IDENTITY) //自增长策略private Long id;private String roleName;private String roleValue;private String roleMatcher;private String enabled;private String remark;public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getRoleName() {return roleName;}public void setRoleName(String roleName) {this.roleName = roleName == null ? null : roleName.trim();}public String getRoleValue() {return roleValue;}public void setRoleValue(String roleValue) {this.roleValue = roleValue == null ? null : roleValue.trim();}public String getRoleMatcher() {return roleMatcher;}public void setRoleMatcher(String roleMatcher) {this.roleMatcher = roleMatcher == null ? null : roleMatcher.trim();}public String getEnabled() {return enabled;}public void setEnabled(String enabled) {this.enabled = enabled == null ? null : enabled.trim();}public String getRemark() {return remark;}public void setRemark(String remark) {this.remark = remark == null ? null : remark.trim();}
}

因为获取的不只是用户信息还包含了角色信心,因此需要根据员工Code查询角色数据

在RoleService中添加对应的方法:

/*** 根据用户id查询所有角色* @param uid* @return*/List<Role> findByUid(Long uid);

在对应的Mapper中添加对应的方法

/*** 根据用户id查询角色信息* @param uid* @return*/List<Role> findByUid(@Param("uid")Long uid);
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="yuan.boke.www.dao.RoleMapper"><select id="findByUid"  resultMap="roleListMap">select id,role_name,role_value,enabled from role where id in(select r.r_id from user u, role_user r where u.id = r.u_id and r.u_id = #{uid}) and enabled =1</select><resultMap type="yuan.boke.www.entity.Role" id="roleListMap"><id property="id" column="id" /><result property="roleName" column="role_name" /><result property="roleValue" column="role_value" /><result property="enabled" column="enabled" /></resultMap>
</mapper>

在实现类中实现其方法RoleServiceImpl 

public class RoleServiceImpl implements RoleService {@AutowiredRoleMapper roleMapper;@Overridepublic List<Role> findByUid(Long uid) {return roleMapper.findByUid(uid);}
}

实现UserDetailsService,创建类AccountDetailsService,重写账户查询返回UserDetails的实体


public class AccountDetailsService implements UserDetailsService {@Autowiredprivate UserService userService;@Autowiredprivate RoleService roleService;@Overridepublic UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {User user = userService.findByEmail(email);if(user == null){throw new UsernameNotFoundException("用户名或密码错误");}List<Role> roles = roleService.findByUid(user.getId());user.setRoles(roles);return user;}
}

继承 UsernamePasswordAuthenticationFilter 过滤器

UsernamePasswordAuthenticationFilter 是处理用户认证逻辑的过滤器,继承它可制定自己的认证逻辑,可以在其中添加自己的验证逻辑处理

通过创建AccountAuthenticationFilter 实现UsernamePasswordAuthenticationFilter过滤器类


public class AccountAuthenticationFilter extends UsernamePasswordAuthenticationFilter {private String codeParameter = "code";@Overridepublic Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {String username = this.obtainUsername(request);String password = this.obtainPassword(request);String code = this.obtainCode(request);String caChecode = (String)request.getSession().getAttribute("VERCODE_KEY");boolean flag = CodeValidate.validateCode(code,caChecode);if(!flag){throw new UsernameNotFoundException("验证码错误");}if(username == null) {username = "";}if(password == null) {password = "";}username = username.trim();UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);this.setDetails(request, authRequest);return this.getAuthenticationManager().authenticate(authRequest);}protected String obtainCode(HttpServletRequest request) {return request.getParameter(this.codeParameter);}
}

将用户名和密码封装到 UsernamePasswordAuthenticationToken 对象中

实现 AccessDeniedHandler 接口

当用户访问未被保护的资源的时候,为了保证其友好性,提供统一的返回

创建MyAccessDeniedHandler实现AccessDeniedHandler类


public class MyAccessDeniedHandler implements AccessDeniedHandler {private String errorPage;@Overridepublic void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {boolean isAjax = "XMLHttpRequest".equals(httpServletRequest.getHeader("X-Requested-With"));if (isAjax) {String jsonObject = "{\"message\":\"Access is denied!\",\"access-denied\":true}";String contentType = "application/json";httpServletResponse.setContentType(contentType);PrintWriter out = httpServletResponse.getWriter();out.print(jsonObject);out.flush();out.close();return;} else {if (!httpServletResponse.isCommitted()) {if (this.errorPage != null) {httpServletRequest.setAttribute("SPRING_SECURITY_403_EXCEPTION", e);httpServletResponse.setStatus(403);RequestDispatcher dispatcher = httpServletRequest.getRequestDispatcher(this.errorPage);dispatcher.forward(httpServletRequest, httpServletResponse);} else {httpServletResponse.sendError(403, e.getMessage());}}}}public void setErrorPage(String errorPage) {if(errorPage != null && !errorPage.startsWith("/")) {throw new IllegalArgumentException("errorPage must begin with '/'");} else {this.errorPage = errorPage;}}
}

spring-security.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:security="http://www.springframework.org/schema/security"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"><security:http security="none" pattern="/css/**" /><security:http security="none" pattern="/js/**" /><security:http security="none" pattern="/images/**" /><security:http security="none" pattern="/favicon.ico"/><security:http security="none" pattern="/login*" /><security:http security="none" pattern="/checkCode"/><security:http security="none" pattern="/checkEmail"/><security:http security="none" pattern="/checkPhone"/><security:http security="none" pattern="/captchaServlet"/><security:http security="none" pattern="/activecode*"/><security:http security="none" pattern="/sendEmail*"/><security:http security="none" pattern="/register*" /><security:http security="none" pattern="/doRegister" /><security:http security="none" pattern="/accessDenied"/><security:http security="none" pattern="/reply"/><security:http auto-config="false" access-decision-manager-ref="accessDecisionManager"use-expressions="true" entry-point-ref="loginEntryPoint"><security:headers><security:frame-options disabled="true"></security:frame-options></security:headers><security:form-login login-page="/login" authentication-failure-url="/login?error=1"login-processing-url="/doLogin" password-parameter="password"default-target-url="/list"username-parameter="username" /><security:access-denied-handler ref="accessDeniedHandler" /><!-- 禁用csrf--><security:csrf disabled="true"/><security:intercept-url pattern="/" access="permitAll"/><security:intercept-url pattern="/index**" access="permitAll"/><security:intercept-url pattern="/sendSms" access="permitAll"/><security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/><!-- session失效url session策略--><security:session-management invalid-session-url="/index.jsp"  session-authentication-strategy-ref="sessionStrategy"></security:session-management><!-- spring-security提供的过滤器 以及我们自定义的过滤器 authenticationFilter--><security:custom-filter ref="logoutFilter" position="LOGOUT_FILTER" /><security:custom-filter before="FORM_LOGIN_FILTER" ref="authenticationFilter"/><security:custom-filter ref="concurrencyFilter" position="CONCURRENT_SESSION_FILTER"/></security:http><bean id="accessDeniedHandler"class="yuan.boke.www.security.account.MyAccessDeniedHandler"><property name="errorPage" value="/accessDenied.jsp" /></bean><bean id="loginEntryPoint"class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"><!-- 默认登录页的url --><constructor-arg value="/login?error=login"/></bean><!-- 启用表达式 为了后面的投票器做准备 --><bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"id="expressionHandler"/><bean class="org.springframework.security.web.access.expression.WebExpressionVoter"id="expressionVoter"><property name="expressionHandler" ref="expressionHandler"/></bean><!-- 认证管理器,使用自定义的accountService,并对密码采用md5加密 --><security:authentication-manager alias="authenticationManager"><security:authentication-provider user-service-ref="accountService"><security:password-encoder hash="md5"><security:salt-source user-property="username"></security:salt-source></security:password-encoder></security:authentication-provider></security:authentication-manager><bean id="authenticationFilter" class="yuan.boke.www.security.account.AccountAuthenticationFilter"><property name="filterProcessesUrl" value="/doLogin"></property><property name="authenticationManager" ref="authenticationManager"></property><property name="sessionAuthenticationStrategy" ref="sessionStrategy"></property><property name="authenticationSuccessHandler"><bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"><property name="defaultTargetUrl" value="/list"></property></bean></property><property name="authenticationFailureHandler"><bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"><property name="defaultFailureUrl" value="/login?error=fail"></property></bean></property></bean><bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"><!-- 处理退出的虚拟url --><property name="filterProcessesUrl" value="/loginout" /><!-- 退出处理成功后的默认显示url --><constructor-arg index="0" value="/login?logout" /><constructor-arg index="1"><!-- 退出成功后的handler列表 --><array><bean id="securityContextLogoutHandler"class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" /></array></constructor-arg></bean><!-- ConcurrentSessionFilter过滤器配置(主要设置账户session过期路径) --><bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"><constructor-arg ref="sessionRegistry"></constructor-arg><constructor-arg value="/login?error=expired"></constructor-arg></bean><bean id="sessionStrategy" class="org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy"><constructor-arg><list><bean class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy"><property name="maximumSessions" value="1"></property><property name="exceptionIfMaximumExceeded" value="false"></property><constructor-arg ref="sessionRegistry"/></bean><bean class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy"/><bean class="org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy"><constructor-arg ref="sessionRegistry"/></bean></list></constructor-arg></bean><bean id="sessionRegistry" scope="singleton" class="org.springframework.security.core.session.SessionRegistryImpl"></bean><bean id="accountService" class="yuan.boke.www.security.account.AccountDetailsService"/><!-- An access decision voter that reads ROLE_* configuration settings --><bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter"/><bean id="authenticatedVoter"class="org.springframework.security.access.vote.AuthenticatedVoter"/><bean id="accessDecisionManager"class="org.springframework.security.access.vote.AffirmativeBased"><constructor-arg><list><ref local="roleVoter"/><ref local="authenticatedVoter"/><ref local="expressionVoter"/></list></constructor-arg></bean></beans>

web.xml 配置

在 web.xml 中配置 Spring Security 的权限过滤器链

 <!-- Spring Security 的权限过滤器链--><filter><filter-name>springSecurityFilterChain</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class></filter><filter-mapping><filter-name>springSecurityFilterChain</filter-name><url-pattern>/*</url-pattern></filter-mapping>

在 web.xml 中引入 spring-security.xml

<context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:spring-mybatis.xml,classpath*:applicationContext-redis.xml,classpath*:applicationContext-activemq.xml,classpath:applicationContext-solr.xml,classpath:spring-security.xml</param-value></context-param>

 

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示

    思路 数值转换为二进制形式(有轮子),然后依次与1比较public int NumberOf1(int n) {int count =0;String string = Integer.toBinaryString(n);char[] c = string.toCharArray();for(int i=0;i<c.length;i++){if(c[i]==1)count++;}return count;}toBinaryString()//生成整…...

    2024/4/5 21:22:18
  2. python做语义网络图

    不多说,直接上代码,大家改一下地址就能用 import re # 正则表达式库 import jieba #分词 import collections # 词频统计库 import numpy as np import pandas as pd import networkx as nx #复杂网络分析库 import matplotlib.pyplot as pltnum=40 G=nx.Graph() plt.figu…...

    2024/3/29 12:54:15
  3. 主流浏览器和内核及Web标准

    目前网络市场的浏览器主流:课时3:web标准 WEB标准 w3c 万维网联盟组织,制定web标准的机构。 网页主要由三部分组成: 结构(Structure)、 表现(Presentation) 行为(Behavior)结构化标准语言:主要是XHTML和XML,用于描述网页。表现标准语言:主要是CSS,用于对网页进行…...

    2024/3/29 12:54:16
  4. docker-以root用户进入容器

    docker-以root用户进入容器 问题描述 有些时候,进入到容器内部不能进行对文件及文件夹的访问,修改和删除,如在搭建jenkins容器的时候,想在容器内部增加文件夹,但是往往系统告知Permission Denied 解决方案# exec方式在退出的时候不会将容器服务关闭 docker exec -it --use…...

    2024/3/29 12:54:13
  5. python爬虫--【百度知道】自动答题

    做的第一个python爬虫类项目,刚开始学,如有错误,指出无妨百度知道自动答题 功能访问百度知道,我们会看到有很多新的提问。 其实很多提问已经有人做了解释或者网上可以找到现成的答案。 因此,一方面,满足那些提问题的人的需要,另一方面,自己使用python练练手。 项目的主…...

    2024/5/1 1:49:10
  6. js基础

    文章目录js基础第一天1、js的作用2、js概念和组成2.1、js概念2.2、js组成3、js注意点4、js中的5中输出语句(前期写js代码,每一句写完加;)5、js中的变量5.4.1、变量使用的几种形式,先声明 再使用5.4.2、变量的命名的规则和规范:5.4.2、交换变量的值:倒可乐(var temp = a; a…...

    2024/3/29 12:54:11
  7. jws的WebService客户端写法

    cmd d:cd D:\javakaifa\jdk1.8\jdk\binwsimport -s D:\\javakaifa\\idea\\xiangmu\\xbiot_fsd_mes20200106\\src -p com.rinsi.fsdmes.base.product.webservice -encoding utf-8 -keep http://192.168.100.187:8100/Erp/ErpIo.asmx?wsdljava自带工具生成Webservice客户端代…...

    2024/3/29 12:54:10
  8. 洛谷P2024 食物链 【并查集】

    标题题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形。A 吃 B,B吃 C,C 吃 A。现有 N 个动物,以 1 - N 编号。每个动物都是 A,B,C 中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这 N 个动物所构成的食物链关系进行描述: 第一种说…...

    2024/3/29 12:54:09
  9. Unity3D学习交流(三)(萌新入)-安卓端触控方式的坑

    JoyStick 之前一直不知道发布到手机上怎么操作,看到网上有人说,桌面端上的鼠标点击和手机上的触控点击是一样的,把电脑上的WSAD键改成四个button就行,鼠标左键攻击也改成手机上的一个button,其他一些功能需要专门学习移动端的触控Touch方法,当时一想,改成button就很简单…...

    2024/4/24 9:46:32
  10. Java实现堆排序

    堆排序使用的是完全二叉树。 即满足r(n)的左孩子是r(2*n+1),右孩子是r(2*n+2)。堆排序它首先将所有的元素添加到堆上,然后不断移除最大的元素并用最后一个叶子结点替换根节点之后再调整堆到大顶堆或者小顶堆的一种排序方法。底层是使用ArrayList进行存储元素的。 大顶堆的概念…...

    2024/3/29 12:54:07
  11. 嵌入式Linux C-shell编程,C开发环境搭建

    正则表达式 1.正则表达式就是用一个字符串来描述一个特征,然后去验证其它字符串是否符合这个特征。 2.[ ]是为解决.号匹配过于广泛的问题,指定一个范围,如 t[aeio]n只能匹配 tan, ten ,tin, ton 3.或运算符| t(a|e|i|o|oo)n 匹配 tan, ten, tin, ton, toon 在LINUX中,正则表…...

    2024/4/23 15:12:20
  12. Monte Carlo methods for improved rendering

    https://smerity.com/montelight-cpp/ overview stochastic ray tracing is one of the fundamental algorithms in computer graphics for generating photo-realistic images. we implement an unbiased monte carlo renderer as an experimental testbed 试验台 for evaluat…...

    2024/3/29 12:54:05
  13. Java多线程-并发工具类Semaphore详解

    文章目录简介应用场景例子注意事项原理初始化方法void acquire()方法void acquire(int permits)方法void acquireUninterruptibly()方法void release()方法void release(int permits)方法 简介 Semaphore是一种同步辅助工具,翻译过来就是信号量,用来实现流量控制,它可以控制同…...

    2024/3/29 7:38:23
  14. Linux下g++编译与使用静态库和动态库

    在windows环境下,我们通常在IDE如VS的工程中开发C++项目,对于生成和使用静态库(.lib)与动态库(.dll)可能都已经比较熟悉,但是,在linux环境下,则是另一套模式,对应的静态库(.a)与动态库(.so)的生成与使用方式是不同的。刚开始可能会不适应,但是用多了应该会习惯这…...

    2024/3/29 7:38:22
  15. offsetWidth,offsetHeigh, offsetLeft, offsetTop,getBoundingClientRect(),clientY,clientX的区别

    e.clientY,e.clientX-----表示的是记录当前的坐标。...

    2024/4/16 2:02:20
  16. 35.Python中join、length、lower、upper、random、safe、slice、truncatechars、truncatechars_html过滤器

    1.join过滤器:类似于中的join,将列表/元组/字符串用指的字符进行拼接,可以在join过滤器之后指定分隔符,示例代码如下: views.py中代码如下: from django.shortcuts import renderdef join(request):context = {value:[python,django,flask]}return render(request,join.ht…...

    2024/4/19 2:16:43
  17. 【NodeJS】04koa 路由 get传值 动态路由

    一、 Koa 路由 路由(Routing)是由一个 URI(或者叫路径)和一个特定的 HTTP 方法(GET、POST 等)组成的,涉及到应用如何响应客户端对某个网站节点的访问。 通俗的讲:路由就是根据不同的 URL 地址,加载不同的页面实现不同的功能。 Koa 中的路由和 Express 有所不同,在 Ex…...

    2024/4/13 20:03:39
  18. 「WC2018」通道(边分治套虚树)

    题目 先考虑两棵树怎么做。 我们在第二棵树的每一个点uuu上再挂一个点u′uu′,他们的距离为第一棵树上的depudep_udepu​。 那么在第二棵树上的两点u′,v′u,vu′,v′的距离就是两棵树上距离总和-u,vu,vu,v在第一棵树上的lcalcalca的深度2\times 22 考虑枚举这个lcalcalca,那…...

    2024/3/29 7:38:18
  19. Spring七种事务传播行为

    事务传播行为 “事务传播行为”描述的是:当一个事务方法被另一个方法调用时,该事务方法如何进行? 是创建新事务?丢弃事务?还是加入到已存在的事务呢? 针对这些情况,Spring框架定义了七种事务传播行为,开发人员可以根据实际的业务场景来选择合适的传播行为。 七种事务传…...

    2024/3/28 20:03:58
  20. Exception processing template "*****": Attribute name cannot be null or em(template学习出现问题一)

    Title代码是这样的。结果问题是自己在写的时候text后面加了个冒号 ,tmd。粗心。...

    2024/3/29 7:38:16

最新文章

  1. 解释Java中的集合框架(Collections Framework)

    Java中的集合框架&#xff08;Collections Framework&#xff09;是一组接口和类的集合&#xff0c;这些接口和类提供了处理对象集&#xff08;例如集合&#xff09;的数据结构和算法。Java集合框架位于java.util包下&#xff0c;它包括几种不同类型的集合&#xff0c;比如列表…...

    2024/5/1 9:48:06
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 设计模式学习笔记 - 设计模式与范式 -行为型:11.迭代器模式(下):如何设计实现一个支持“快照”功能的Iterator

    概述 前两篇文章&#xff0c;学习了迭代器模式的原理、实现&#xff0c;并分析了在遍历集合的同时增删元素集合&#xff0c;产生不可预期结果的原因及应对策略。 本章&#xff0c;再来看这样一个问题&#xff1a; 如何实现一个支持 “快照” 功能的迭代器&#xff1f; 这个问…...

    2024/4/24 4:00:31
  4. 《前端防坑》- JS基础 - 你觉得typeof nullValue === null 么?

    问题 JS原始类型有6种Undefined, Null, Number, String, Boolean, Symbol共6种。 在对原始类型使用typeof进行判断时, typeof stringValue string typeof numberValue number 如果一个变量(nullValue)的值为null&#xff0c;那么typeof nullValue "?" const u …...

    2024/5/1 8:48:40
  5. Linux从入门到精通 --- 2.基本命令入门

    文章目录 第二章&#xff1a;2.1 Linux的目录结构2.1.1 路径描述方式 2.2 Linux命令入门2.2.1 Linux命令基础格式2.2.2 ls命令2.2.3 ls命令的参数和选项2.2.4 ls命令选项的组合使用 2.3 目录切换相关命令2.3.1 cd切换工作目录2.3.2 pwd查看当前工作目录2.4 相对路径、绝对路径和…...

    2024/4/30 5:12:27
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/4/29 23:16:47
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/4/30 18:14:14
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/4/29 2:29:43
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/4/30 18:21:48
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/4/27 17:58:04
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/4/27 14:22:49
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/4/28 1:28:33
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/4/30 9:43:09
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/4/27 17:59:30
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/4/25 18:39:16
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/4/28 1:34:08
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/4/26 19:03:37
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/4/29 20:46:55
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/4/30 22:21:04
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/1 4:32:01
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/4/27 23:24:42
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/4/28 5:48:52
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/4/30 9:42:22
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/4/30 9:43:22
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/4/30 9:42:49
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57