cas 5.2.0登陆界面添加验证码和校验功能

2023-11-10

本文分为4个部分:
1.登录界面添加验证码
2.自定义登录对象,增加一个验证码字段
3.自定义cas的登录流程,完成自定义校验
4.返回自定错误信息

1、配置验证码

生成验证码,使用google的kaptcha,需引入jar的包如下

        <dependency>
            <groupId>com.github.penggle</groupId>
            <artifactId>kaptcha</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apereo.cas</groupId>
            <artifactId>cas-server-core-configuration</artifactId>
            <version>${cas.version}</version>
        </dependency>

配置验证码,以下是我自己的配置,大家可根据自身需要进行修改,网上有很多kaptcha配置参数详解

package com.zee.custom.captcha.config;

import javax.servlet.ServletException;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.code.kaptcha.servlet.KaptchaServlet;

@Configuration
public class KaptchaConfig {

    @Bean
    public ServletRegistrationBean servletRegistrationBean() throws ServletException {
        ServletRegistrationBean servlet = new ServletRegistrationBean(new KaptchaServlet(),  "/images/kaptcha.jpg");//加载路径
        servlet.addInitParameter("kaptcha.border", "no"/* kborder */);// 无边框
        servlet.addInitParameter("kaptcha.session.key", "captcha");// session key
        servlet.addInitParameter("kaptcha.textproducer.font.color", "black");
        servlet.addInitParameter("kaptcha.textproducer.font.size", "25");
        servlet.addInitParameter("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.WaterRipple");
        servlet.addInitParameter("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
        servlet.addInitParameter("kaptcha.image.width", "90");
        servlet.addInitParameter("kaptcha.image.height", "33");
        servlet.addInitParameter("kaptcha.textproducer.char.length", "4");
        servlet.addInitParameter("kaptcha.textproducer.char.space", "5");
        servlet.addInitParameter("kaptcha.background.clear.from", "247,247,247"); // 和登录框背景颜色一致
        servlet.addInitParameter("kaptcha.background.clear.to", "247,247,247");
        return servlet;
    }
}

配置spring.factories 文件

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.zee.custom.captcha.config.KaptchaConfig,

登录界面

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
     <script type="text/javascript" th:src="@{/themes/captcha/js/jquery.min.js}" ></script>
    <script type="text/javascript" th:src="@{/themes/captcha/js/code.js}" ></script>
</head>
<body>

<h2>默认的登录模板</h2>
<div id="casLoginContent">
    <form method="post" th:object="${credential}">
        <div th:if="${#fields.hasErrors('*')}">
            <span th:each="err : ${#fields.errors('*')}" th:utext="${err}"/>
        </div>
        <h2 th:utext="#{screen.welcome.instructions}"></h2>

        <section class="row">
            <label for="username" th:utext="#{screen.welcome.label.netid}"/>
            <div th:unless="${openIdLocalId}">
                <input class="required"
                       id="username"
                       size="25"
                       tabindex="1"
                       type="text"
                       th:disabled="${guaEnabled}"
                       th:field="*{username}"
                       th:accesskey="#{screen.welcome.label.netid.accesskey}"
                       autocomplete="off"/>
            </div>
        </section>

        <section class="row">
            <label for="password" th:utext="#{screen.welcome.label.password}"/>
            <div>
                <input class="required"
                       type="password"
                       id="password"
                       size="25"
                       tabindex="2"
                       th:accesskey="#{screen.welcome.label.password.accesskey}"
                       th:field="*{password}"
                       autocomplete="off"/>
            </div>
        </section>
        <!-- 验证码信息 @{/captcha} -->
        <section>
            <img id="captcha_img" th:src="@{/images/kaptcha.jpg}" onclick="changeCode()" style="width: 125px;"/>
            <input type="text" th:field="*{captcha}" id="code"/>
            <span id="code_str"></span>
        </section>
        <section>
            <input type="hidden" name="execution" th:value="${flowExecutionKey}"/>
            <input type="hidden" name="_eventId" value="submit"/>
            <input type="hidden" name="geolocation"/>
            <input class="btn btn-submit btn-block"
                   name="submit"
                   accesskey="l"
                   th:value="#{screen.welcome.button.login}"
                   tabindex="6"
                   type="submit"/>
        </section>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
function changeCode(){
    //刷新验证码
    $("#captcha_img").attr('src','/cas/images/kaptcha.jpg?id='+Math.random());
}
</script>

2、自定义登录对象

自定义一个表单对象,需要继承默认的RememberMeUsernamePasswordCredential,添加一个验证码字段

package com.zee.custom.pojo;

import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential;

public class CusLoginUserInfoEntity extends RememberMeUsernamePasswordCredential {

    private static final long serialVersionUID = 1L;

    private String captcha;

    public String getCaptcha() {
        return captcha;
    }

    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

}

由于cas使用的是webflow所以我们还需要那自定义的登录对象绑定到页面上

package com.zee.custom.mongo.webflow;

import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.web.flow.CasWebflowConstants;
import org.apereo.cas.web.flow.configurer.AbstractCasWebflowConfigurer;
import org.springframework.context.ApplicationContext;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.engine.builder.BinderConfiguration;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;

import com.zee.custom.pojo.CusLoginUserInfoEntity;

public class CustomWebflowConfigurer extends AbstractCasWebflowConfigurer {
    /**
     * 校验码动作
     */
    public static final String VALIDATE_CAPTCHA_ACTION = "validateCaptchaAction";

    public CustomWebflowConfigurer(FlowBuilderServices flowBuilderServices,
            FlowDefinitionRegistry loginFlowDefinitionRegistry, ApplicationContext applicationContext,
            CasConfigurationProperties casProperties) {
        super(flowBuilderServices, loginFlowDefinitionRegistry, applicationContext, casProperties);
        // TODO Auto-generated constructor stub
    }

    // 绑定验证码信息
    protected void doInitialize() {
        final Flow loginFlow = getLoginFlow();
        // 重写绑定自定义credential
        createFlowVariable(loginFlow, CasWebflowConstants.VAR_ID_CREDENTIAL, CusLoginUserInfoEntity.class);
        // 获取登录页
        final ViewState state = (ViewState) loginFlow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
        // 获取参数绑定对象
        final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
        // 由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
        // 参数1 :字段名
        // 参数2 :转换器
        // 参数3 :是否必须的字段
        cfg.addBinding(new BinderConfiguration.Binding("captcha", null, true));

    }

}

然后把自定义的CustomWebflowConfigurer注册到spring容器中

package com.zee.custom.mongo.config;

import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.web.flow.CasWebflowConfigurer;
import org.apereo.cas.web.flow.config.CasWebflowContextConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;

import com.zee.custom.mongo.webflow.CustomWebflowConfigurer;

@Configuration
@EnableConfigurationProperties(CasConfigurationProperties.class)
@AutoConfigureBefore(value = CasWebflowContextConfiguration.class)
public class CustomWebFlowConfig {
    @Autowired
    private CasConfigurationProperties casProperties;

    @Autowired
    // @Qualifier("loginFlowRegistry")
    private FlowDefinitionRegistry loginFlowRegistry;

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private FlowBuilderServices flowBuilderServices;

    // 注册自定义的webFlow
    @Bean
    public CasWebflowConfigurer customWebflowConfigurer() {
        // 实例化自定义的表单配置类
        final CustomWebflowConfigurer c = new CustomWebflowConfigurer(flowBuilderServices, loginFlowRegistry,
                applicationContext, casProperties);
        // 初期化
        c.initialize();
        // 返回对象
        return c;
    }
}

配置spring.factories 文件

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.zee.custom.captcha.config.KaptchaConfig,\
com.zee.custom.mongo.config.CustomWebFlowConfig

3、自定义cas的登录校验流程

新建一个类继承AbstractPreAndPostProcessingAuthenticationHandler 这个类,重写cas是默认登录流程,自定义登录参数的校验

import static com.mongodb.client.model.Filters.eq;

import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.security.auth.login.AccountLockedException;
import javax.security.auth.login.AccountNotFoundException;
import javax.servlet.http.HttpServletRequest;

import org.apereo.cas.authentication.Credential;
import org.apereo.cas.authentication.HandlerResult;
import org.apereo.cas.authentication.PreventedException;
import org.apereo.cas.authentication.UsernamePasswordCredential;
import org.apereo.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler;
import org.apereo.cas.authentication.principal.PrincipalFactory;
import org.apereo.cas.services.ServicesManager;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.pac4j.core.exception.MultipleAccountsFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.zee.custom.mongo.exception.CusCaptchaException;
import com.zee.custom.mongo.utils.CryptoUtil;import com.zee.custom.pojo.CusLoginUserInfoEntity;


public class CustomMongoAuthenticationHandler extends AbstractPreAndPostProcessingAuthenticationHandler {
    @Autowired
    private MongoClient mongoClient;

    public CustomMongoAuthenticationHandler(String name, ServicesManager servicesManager, PrincipalFactory principalFactory,
            Integer order) {
        super(name, servicesManager, principalFactory, order);
    }

    @Override
    public boolean supports(Credential credential) {
        // TODO Auto-generated method stub
        System.out.println("被调用了");
        return credential instanceof UsernamePasswordCredential;
    }

    /*
     * 验证码,自定义验证, 验证用户名密码是否正确
     */
    protected HandlerResult doAuthentication(Credential credential)
            throws GeneralSecurityException, PreventedException {

        final CusLoginUserInfoEntity myCredential = (CusLoginUserInfoEntity) credential;
        // 通过SpringMvc封装的方法获得本次请求的request
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
                .getRequest();
        //获取存储在Session中的验证码
        String captcha = request.getSession().getAttribute("captcha").toString();
        if (!myCredential.getCaptcha().equals(captcha)) {
            //此处抛出的是自定义异常,后面说明如何自定义异常,自定义返回错误信息
            throw new CusCaptchaException("验证码错误");
        }
        System.out.println(request.getSession().getAttribute("captcha"));
        //自定义其他校验
    }

}

自定义的验证处理流程注册到spring容器中

package com.zee.custom.mongo.config;

import org.apereo.cas.authentication.AuthenticationEventExecutionPlan;
import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer;
import org.apereo.cas.authentication.AuthenticationHandler;
import org.apereo.cas.authentication.principal.DefaultPrincipalFactory;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.services.ServicesManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.zee.custom.mongo.handler.CustomMongoAuthenticationHandler;

@Configuration("CustomAuthenticationHandlerConfiguration")
@EnableConfigurationProperties(CasConfigurationProperties.class)
public class CustomAuthenticationHandlerConfiguration implements AuthenticationEventExecutionPlanConfigurer {
    @Autowired
    @Qualifier("servicesManager")
    private ServicesManager servicesManager;

    // 注册验证器
    @Bean
    public AuthenticationHandler customAuthenticationHandler() {
        return new CustomMongoAuthenticationHandler("customAuthenticationHandler", servicesManager,
                new DefaultPrincipalFactory(), 1);
    }

    // 注册自定义认证器
    public void configureAuthenticationExecutionPlan(AuthenticationEventExecutionPlan plan) {
        // TODO Auto-generated method stub
        plan.registerAuthenticationHandler(customAuthenticationHandler());
    }

}

配置spring.factories 文件,完整的spring.factories 文件

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.zee.custom.mongo.config.CustomAuthenticationHandlerConfiguration,\
com.zee.custom.captcha.config.KaptchaConfig,\
com.zee.custom.mongo.config.CustomWebFlowConfig

4、自定义返回错误信息

当输入的验证码不正确时,我们需要自定义异常和错误信息
创建异常类,需要继承AccountExpiredException这个类

package com.zee.custom.mongo.exception;

import javax.security.auth.login.AccountExpiredException;

public class CusCaptchaException extends AccountExpiredException {

    private static final long serialVersionUID = 1L;

    public CusCaptchaException() {
        super();
        // TODO Auto-generated constructor stub
    }

    public CusCaptchaException(String msg) {
        super(msg);
        // TODO Auto-generated constructor stub
    }
}

配置application.properties

#自定义异常,多个逗号隔开
cas.authn.exceptions.exceptions= com.zee.custom.mongo.exception.CusCaptchaException

把cas原来的messages_zh_CN.properties文件复制到src/mian/resources目录下面,并配置需要提示的信息

#自定义字段如果为必须输入,当为null时,提示信息格式为  字段名+required
captcha.required=必须输入验证码
#自定义异常信息格式为 authenticationFailure+异常类名
authenticationFailure.CusCaptchaException=验证码错误

最终的项目结构

这里写图片描述

参考文章:https://blog.csdn.net/yelllowcong/article/category/7347371

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cas 5.2.0登陆界面添加验证码和校验功能 的相关文章

  • cas mysql_CAS服务器动态验证,CAS使用MySQL数据库验证-(二)

    步骤 一 搭建CAS服务器 gt 二 修改application properties 静态验证的配置 xff0c 需要注释 xff1a CAS Authentication Credentials cas authn accept use
  • 阿里云docker方式搭建CAS服务端-最新版

    现在网上查到的CAS服务端搭建方式都比较老 xff0c 坑也很多 docker镜像直接使用官方的 xff0c 便于今后无缝升级 cas现时点最新版本为6 3 1 创建工作目录 mkdir home cas 以下操作都在该目录下执行 2 生成
  • 搭建Cas服务

    环境要求 JDK 1 8CAS 5 3tomcat 9 1 cas项目下载地址 xff1a https github com apereo cas overlay template tree 5 3 2 使用idea导入cas overla
  • 使用cas-overlay-template 6.2服务部署到整合cas-client

    1 什么sso是单点登录 单点登录 xff08 Single Sign On xff09 xff0c 简称为 SSO xff0c 是比较流行的企业业务整合的解决方案之一 SSO的定义是在多个应用系统中 xff0c 用户只需要登录一次就可以访
  • CAS 服务端的搭建

    上文讲了CAS客户端 xff0c 本文记录CAS Server的搭建步骤 CAS Server的版本一定要选好 xff0c 我选的是CAS5 3 xff0c Java版本用的8 xff0c 目前最新的CAS6 5的Java版本最低是11了
  • SSO、CAS、OAuth、OIDC

    参考 简单了解概念 xff1a https www bilibili com video BV1XG411w7DN 简单了解操作 xff1a https www bilibili com video BV1334y11739 openid
  • 单点登录CAS学习(一):初识单点登录

    一 单点登录应用场景 不少业主单位随着自身的发展 建立不少业务支撑系统 往往会采用不同的开发商进行系统开发和建设 因此必然形成如下一种局面 工作人员需要登录多个业务系统才能将自己的工作全部完成 给工作人员带来了额外的负担 因此单点登录变应运
  • AtomicInteger、Unsafe类、ABA问题

    AtomicInteger Java中的AtomicInteger大家应该很熟悉 它是为了解决多线程访问Integer变量导致结果不正确所设计的一个基于多线程并且支持原子操作的Integer类 AtomicInteger内部有一个变量UnS
  • SpringBoot 搭建CAS 客户端 和CAS 服务端

    第一步 搭建CAS5 3 服务端 Github 下载CAS5 3 服务端版本 https github com apereo cas overlay template tree 5 3 注意 最新的master分支使用的需要java11 该
  • Cas服务端5.3 基于MySQL8数据库,实现用户认证

    第一步 Cas 服务端添加数据库认证依赖jar 文件 找到下图所示代码端 添加如下依赖jar包
  • Cas5.3服务器集成DM8 达梦数据库

    DM8达梦数据库相关准备 1 安装DM8达梦数据库并安装相关数据库实例 省略一千字 2 新建ucas auth user表 并增加相关用户条记录 DROP TABLE IF EXISTS ucas auth user CREATE TABL
  • 经典的ABA问题与解决方法

    1 AbA问题的产生 要了解什么是ABA问题 首先我们来通俗的看一下这个例子 一家火锅店为了生意推出了一个特别活动 凡是在五一期间的老用户凡是卡里余额小于20的 赠送10元 但是这种活动没人只可享受一次 然后火锅店的后台程序员小王开始工作了
  • 【Python开发】Flask中的单点登录解决方案

    Flask中的单点登录解决方案 1 SSO 和 CAS 单点登录 Single Sign On SSO 就是通过用户的一次性鉴别登录 当用户在身份认证服务器上登录一次以后 即可获得访问单点登录系统中其他关联系统和应用软件的权限 同时这种实现
  • CAS AD LDAP 32 错误

    当我尝试使用 CAS 登录时 我看到了这一点 CAS 通过 LDAP 对 AD 进行身份验证 SEVERE Servlet service for servlet cas threw exception javax naming NameN
  • CAS 服务票证验证失败

    我已点击链接http lukesampson com post 315838839 cas on windows localhost setup in 5 mins 则cas服务器工作正常 登录url为http 10 1 1 26 8080
  • 如何实施单点登录

    我想实现 SSO 单点登录 我发现了很多关于 CAS OpenID 和许多不同事物的链接和文章 我真的迷失了那么我应该使用 CAS 吗 我安装了 CAS Server 并将其部署到 Tomcat 中 你下一步怎么做 或者这是错误的 您能解释
  • javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:不存在主题备用名称

    基本上 我有一个测试服务器 基于 Linux 带有公共 IP 机器人 没有公共主机名 所以我尝试使用 IP 地址为其创建 ssl 证书 这样我的 Java 应用程序就可以使用 IP 地址访问另一个应用程序 例如 https 210 10 1
  • CodeIgniter 的 CAS 身份验证库

    我正在尝试在 CodeIgniter 应用程序中实现 CAS 身份验证 但我找不到当前是否有为其设置的库 我通过只包含类并添加一些肮脏的修复来进行管理 但如果有人知道合适的库 我认为这将是一个更干净的解决方案 我一直在浏览这里以及谷歌上的一
  • 如何将 AngularJS 路由与 CAS 身份验证重定向一起使用,或者 Angular 不可用?

    我的应用程序通常使用以下路由 http angularapp com page bannanas http angularapp com page bannanas 但是 如果用户未经过身份验证 则用户将被重定向到 CAS 登录页面 然后登
  • 如何使用第三方 CAS 身份验证从独立的 React 前端和 django 后端(相同域,不同端口)对用户进行身份验证?

    我正在设置 django 后端Django REST framework用于提供API 通过第三方CAS服务器实现身份验证 目前我的后端认证已经成功实现 使用django cas ngpackage 这意味着我可以为不同的用户组实现不同的权

随机推荐

  • vsqt中导出工程的Pro文件

    直接在qtvstools中使用Create Basic pro File所产生的Pro与Pri文件无法打开原工程 正确的做法应该是先用Export Project to pri File导出Pri文件后再使用Create Basic pro
  • C语言动态内存练习:【通讯录(动态内存版本)实现】

    全文目录 前言 目标规划 结构变化 功能实现的不同点 添加功能 AddContact 扩容检查 CheckCapacity 销毁通讯录 DestroyContact 总结 源码 前言 前面我们写了一个静态数组版本的通讯录 再结合刚学习的动态
  • bug记录 bigint数据返回前端数字精度丢失

    我的主键是bigint 9607408720124535 但是前端展示就是9607408720124536 使用postman调用就是9607408720124535 正确的 最终确定是js的number类型有个最大安全值 即2的53次方
  • JavaFX通过Controller类实现第二窗口销毁和程序退出

    Preface Q 为什么有此文 A 不能高度自定义化 网上大部分文章是通过简易的warning窗口 或者 information窗口实现的 且过于繁琐 大部分放在了Main java 不好弄 原理 Controller类中关键性代码 具体
  • MYSQL——模糊查询:like

    模糊查询指的是在数据中按照一定模糊的条件进行搜索 模糊查询的核心在于通配符的使用 通过使用通配符可以匹配不同的字符或字符串 一般模糊查询语句如下 SELECT 字段 FROM 表 WHERE 某个字段 LIKE 条件 表示任意0个或多个字符
  • css 背景效果_软件技术:我写CSS的常用套路(附demo的效果实现与源码)

    前言 本文是笔者写CSS时常用的套路 不论效果再怎么华丽 万变不离其宗 1 交错动画 有时候 我们需要给多个元素添加同一个动画 播放后 不难发现它们会一起运动 一起结束 这样就会显得很平淡无奇 那么如何将动画变得稍微有趣一点呢 很简单 既然
  • Harbor仓库介绍与搭建过程

    一 介绍 Harbor 是一个英文单词 意思是港湾 港湾是干什么的呢 就是停放货物的 而货物呢 是装在集装箱中的 说到集装箱 就不得不提到Docker容器 因为docker容器的技术正是借鉴了集装箱的原理 所以 Harbor正是一个用于存储
  • mysql数据库知识整理

    目录 InnoDB和MyISAM引擎常见区别 索引的基本原理 聚簇索引和非聚簇索引的区别 索引的数据结构及优势 索引的设计原则 innerdb主键索引自增的原因以及联合索引最左原则 锁的类型有哪些 MySQL执行计划 InnoDb引擎的执行
  • 关于网络编程里自定义序列化(字节化)遇到的坑

    1 结构体字节流化可能会出现的问题 网络编程里很多时候需要发送结构体 比如下面定义一个最简单的拥有多个元素的结构体 typedef struct msg int len char name 24 msg t 在保持客户端和服务端程序的结构体
  • Servlet实现文件上传

    定义 在Servlet3 0之前实现文件上传需要借助Apache的上传组件 在3 0中 提供了一个Servlet API标准去支持文件上传 上传前置 表单页面设置 设置enctype属性格式为multipart form data meth
  • flutter多种底部导航栏样式

    1 底部导航栏 外弧样式 实现代码 引入flutter的dart库 import package flutter material dart 启动函数 void main gt runApp MyApp 自定义组件 class MyApp
  • springboot中使用注解获取前台header信息

    今天在写vue时 需要实现一个功能 就是前台通过header 请求头 将token发送到服务端 后台使用的是springboot 第一下想到是springboot注解 但是百度了挺久发现很多人都是使用的原生servlet对象来获取头信息 其
  • 【Educoder python 作业答案】国防科技大学《大学计算机基础》※ 冯·诺依曼体系结构——模拟 TOY 计算机(MOOC版)

    Educoder python 作业答案 国防科技大学 大学计算机基础 冯 诺依曼体系结构 模拟 TOY 计算机 MOOC版 第1关 程序加载 第2关 执行一条指令 第3关 自动执行 TOY 程序 第1关 程序加载 mem 1000 初始化
  • Effective C++ 条款十二:复制对象时勿忘其每一个成分

    这句话包含两部分的意思 第一部分是要考虑到所有成员变量 特别是后加入的 相应的拷贝构造函数和赋值运算符要及时更新 第二部分是在存在继承时 不要遗忘基类部分的复制 先看第一部分的意思 举个例子 class SampleClass privat
  • [Python人工智能] 二.TensorFlow基础及一元直线预测案例

    从本篇文章开始 作者正式开始研究Python深度学习 神经网络及人工智能相关知识 前一篇文章讲解了TensorFlow的安装过程和神经网络基础概念 这篇文章将分享TensorFlow基础并介绍一元直线预测的案例 主要结合作者之前的博客和 莫
  • ubuntu升级python版本(3.5->3.6)

    安装aioredis时提示Python版本需 gt 3 5 3 所以进行升级 命令如下 获取最新的python3 6 将其添加至当前apt库中 并自动导入公钥 sudo add apt repository ppa jonathonf py
  • Tomcat日志文件过大导致系统故障处理办法

    1 远程登录系统 2 查看日志文件 catalina out 文件大小 root localhost cd usr local apache tomcat logs root localhost logs du h catalina out
  • 创建Javaweb、导入jar包、配置Tomcat

    一 第一大步 新建一个项目 文件 新建 项目 空项目 项目名称 可以随便起 与3要保持一致 一般情况3会在2后自动生成 点完成即可 第二大步 新建模块 文件 新建 模块 java模块 点击下一步即可 模块名称 起名字 完成 第三大步 让模块
  • mac pro 安装arduino ide 驱动

    mac pro 安装arduino ide 需要安装额外驱动去识别USB 直接安装下面文件即可解决
  • cas 5.2.0登陆界面添加验证码和校验功能

    本文分为4个部分 1 登录界面添加验证码 2 自定义登录对象 增加一个验证码字段 3 自定义cas的登录流程 完成自定义校验 4 返回自定错误信息 1 配置验证码 生成验证码 使用google的kaptcha 需引入jar的包如下