boke练习: springboot整合springSecurity出现的问题,传递csrf

freemarker模板

在html页面中加入:

<input name="_csrf" type="hidden" value="${_csrf.token}">
<input name="_csrf_header" type="hidden" value="${_csrf.headerName}"/>

  

在ajax代码中加入, beforeSend或headers

beforeSend: function(request) {
request.setRequestHeader(data.field._csrf_header, data.field._csrf);
},

  

如下

ajax({
type: 'POST',
url: "/comment", // ajax请求路径
data: {
blogId: data.field.blogId,
commentContext: data.field.desc,
},
beforeSend: function(request) {
request.setRequestHeader(data.field._csrf_header, data.field._csrf);
},
success: function(data){
layer.msg("评论成功!");
showComments(${blogModel.id});
},error:function()
{
layer.msg("评论失败!");
}
});

  

boke练习: springboot整合springSecurity出现的问题,传递csrf的更多相关文章

  1. SpringBoot整合SpringSecurity简单实现登入登出从零搭建

    技术栈 : SpringBoot + SpringSecurity + jpa + freemark ,完整项目地址 : https://github.com/EalenXie/spring-secu ...

  2. SpringBoot整合SpringSecurity示例实现前后分离权限注解

    SpringBoot 整合SpringSecurity示例实现前后分离权限注解+JWT登录认证 作者:Sans_ juejin.im/post/5da82f066fb9a04e2a73daec 一.说 ...

  3. 9、SpringBoot整合之SpringBoot整合SpringSecurity

    SpringBoot整合SpringSecurity 一.创建项目,选择依赖 选择Spring Web.Thymeleaf即可 二.在pom文件中导入相关依赖 <!-- 导入SpringSecu ...

  4. boke练习: springboot整合springSecurity出现的问题,post,delete,put无法使用

    springboot 与 SpringSecurity整合后,为了防御csrf攻击,只有GET|OPTIONS|HEAD|TRACE|CONNECTION可以通过. 其他方法请求时,需要有token ...

  5. SpringBoot整合SpringSecurity实现JWT认证

    目录 前言 目录 1.创建SpringBoot工程 2.导入SpringSecurity与JWT的相关依赖 3.定义SpringSecurity需要的基础处理类 4. 构建JWT token工具类 5 ...

  6. springboot整合springsecurity遇到的问题

    在整合springsecurity时遇到好几个问题,自动配置登录,下线,注销用户的操作,数据基于mybatis,模版引擎用的thymeleaf+bootstrap. 一.认证时密码的加密(passwo ...

  7. SpringBoot 整合 SpringSecurity 梳理

    文档 Spring Security Reference SpringBoot+SpringSecurity+jwt整合及初体验 JSON Web Token 入门教程 - 阮一峰 JWT 官网 Sp ...

  8. SpringBoot整合SpringSecurity简单案例

    在我们开发项目的过程中经常会用到一些权限管理框架,Java领域里边经常用的可能就是shiro了,与之对应的还有SpringSecurity,SpringSecurity可以说是非常强大,与Spring ...

  9. SpringBoot整合SpringSecurity,SESSION 并发管理,同账号只允许登录一次

    重写了UsernamePasswordAuthenticationFilter,里面继承AbstractAuthenticationProcessingFilter,这个类里面的session认证策略 ...

随机推荐

  1. Codeforces 711D Directed Roads - 组合数学

    ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it co ...

  2. 【python35.2--图形用户界面EasyGui】

    一.猜字游戏 #猜字游戏(从1到10) import easygui as g import random g.msgbox('欢迎进入探险之路!') screct = random.randint( ...

  3. 盛世狂欢意犹未尽之恋舞OL折扣平台多角度体验

    2018国民级时尚音乐舞蹈手游<恋舞OL>,女生都爱玩的手机游戏.画风Q萌的3D音乐舞蹈手游,多人同时在线,玩法轻松休闲,浪漫场景自由社交互动,恋上指尖舞蹈. 小编看了上述介绍之后,感觉已 ...

  4. How Flyway works

    The easiest scenario is when you point Flyway to an empty database. It will try to locate its schema ...

  5. 比较好的MySQL索引原理

    MySQL索引原理及慢查询优化 - 美团技术团队 https://tech.meituan.com/2014/06/30/mysql-index.html

  6. nohup 让进程在后台可靠运行的几种方法

    1. nohup nohup 无疑是我们首先想到的办法.顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号. nohup 的使用是十分方便的,只需在要处理的命令前加上 nohup 即 ...

  7. oracle 之 定时任务,存储过程和游标等语法案例

    --定时任务 declare job20 number; begin sys.dbms_job.submit(job20,'test1;',sysdate,'sysdate+1'); end; --存 ...

  8. POJ 2409 Let it Bead

    思路 同这道题,只是颜色数从3变成c 代码 #include <cstdio> #include <algorithm> #include <cstring> #d ...

  9. [JavaScript] - js

    原题 var countSheep = function (num){ //your code here var str = ' sheep...'; var result = ''; for (va ...

  10. 用Qemu模拟vexpress-a9 --- 配置 qemu 的网络功能

    转载:http://wiki.sylixos.com/index.php/Linux%E7%8E%AF%E5%A2%83%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97 环境介 ...