码迷,mamicode.com
首页 > 数据库 > 详细

SqlSession was not registered for synchronization异常

时间:2021-02-09 12:21:31      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:util   成功   异常   登录失败   because   ext   tis   tsv   cat   

今天在写项目时遇到如下错误

js代码如下,layui弹出层没有弹出,控制台也得不到输出

$(document).on(‘click‘,‘#login‘,function(){
            let name = $("#name").val();
            let password = $("#password").val();
            $.ajax({
                type:‘post‘,
                url:‘${pageContext.request.contextPath}/adminLogin‘,
                data:{‘name‘:name,‘password‘:password},
                dataType:‘text‘,
                success:function(result){
                    if (result ** "success"){
                        console.log("2132123123123123");
                        layer.msg(‘登录成功‘, {
                            offset: ‘15px‘
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            location.href = ‘${pageContext.request.contextPath}/index‘; //后台主页
                        });
                    }else if(result ** "fail"){
                        layer.msg(‘登录失败,请检查账号或密码是否正确.‘, {
                            offset: ‘15px‘
                            ,icon: 2
                            ,time: 1000
                        });
                    }
                }
            })
        });

同时控制台报错,错误内容如下

Uncaught TypeError: Cannot read property ‘toLowerCase‘ of undefined
    at HTMLDocument.eval (eval at <anonymous> (eval at ExRmtSvrCd (eval at <anonymous> (pin.js:155))), <anonymous>:1:29732)  

一直以为是我js的问题,又在代码中打印发现错误

@RequestMapping("/adminLogin")
    @ResponseBody
    public String adminLogin(String userName,String userPassword){
        Admin admin = service.queryAdmin(userName,userPassword);
        System.out.println("1111111111111111111111111111111");
        if (admin!=null){
            return "success";
        }else{
            return "fail";
        }
    }
[org.mybatis.spring.SqlSessionUtils]-Creating a new SqlSession
[org.mybatis.spring.SqlSessionUtils]-SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@292f2501] was not registered for synchronization because synchronization is not active
[org.mybatis.spring.SqlSessionUtils]-Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@292f2501]

最后通过查资料得到解决方案

在对应方法上添加@Param注解即可解决

技术图片
技术图片

SqlSession was not registered for synchronization异常

标签:util   成功   异常   登录失败   because   ext   tis   tsv   cat   

原文地址:https://www.cnblogs.com/destiny-log/p/14390191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!