zoukankan      html  css  js  c++  java
  • 常用问题总结

    HTTP 400 错误 - 请求无效 (Bad request)

    在ajax请求后台数据时有时会报 HTTP 400 错误 - 请求无效 (Bad request);出现这个请求无效报错说明请求没有进入到后台服务里;
    原因:1)前端提交数据的字段名称或者是字段类型和后台的实体类不一致,导致无法封装;
         2)前端提交的到后台的数据应该是json字符串类型,而前端没有将对象转化为字符串类型;
    案例:当使用springmvc接受前端页面的请求时,前端传递的日期格式是yyyy-mm-dd,而后端默认接收的日期格式是yyyy/mm/dd,导致前端访问后端无法访问到,出现400错误。

    java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

    这类的问题大多都是数据库执行的sql语句格式不正确引起,大多可以通过检查sql拼写能够发现问题出现在哪里。如果肉眼观察不到,可以通过调试代码,在数据库实际执行sql语句前来查看具体的sql语句。
    mybatis的排查方法:在BaseStatementHandler类的构造函数上打上断点,进入调试后,查看boundSql的值,即可发现问题所在之处。

      protected BaseStatementHandler(Executor executor, MappedStatement mappedStatement, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
        this.configuration = mappedStatement.getConfiguration();
        this.executor = executor;
        this.mappedStatement = mappedStatement;
        this.rowBounds = rowBounds;

        this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
        this.objectFactory = configuration.getObjectFactory();

        if (boundSql == null) { // issue #435, get the key before calculating the statement
          generateKeys(parameterObject);
          boundSql = mappedStatement.getBoundSql(parameterObject);
        }

        this.boundSql = boundSql;

        this.parameterHandler = configuration.newParameterHandler(mappedStatement, parameterObject, boundSql);
        this.resultSetHandler = configuration.newResultSetHandler(executor, mappedStatement, rowBounds, parameterHandler, resultHandler, boundSql);
      }

     tomcat7.0.94和tomcat8.5.42启动时,控制台乱码

    1.打开你安装Tomcat的所在目录
    2.打开后选择conf目录。
    3.将里面的logging.properties文件用编辑器打开
    5.修改为java.util.logging.ConsoleHandler.encoding = GBK;
    6.重新启动Tomcat就可以了。
    

      

    剩余继续更新...

  • 相关阅读:
    区别@ControllerAdvice 和@RestControllerAdvice
    Cannot determine embedded database driver class for database type NONE
    使用HttpClient 发送 GET、POST、PUT、Delete请求及文件上传
    Markdown语法笔记
    Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    Mysql 查看连接数,状态 最大并发数(赞)
    OncePerRequestFilter的作用
    java连接MySql数据库 zeroDateTimeBehavior
    Intellij IDEA 安装lombok及使用详解
    ps -ef |grep xxx 输出的具体含义
  • 原文地址:https://www.cnblogs.com/lpob/p/10852600.html
Copyright © 2011-2022 走看看