• SSH项目中遇到的问题


    1.

    Struts has detected an unhandled exception:
    
    Messages: antlr.collections.AST.getLine()I
    File:	org/hibernate/hql/internal/ast/HqlSqlWalker.java
    Line number:	929
    

      这个问题,每次都是重新编译后还会出现这个异常,原因是Struts2框架自带antlr2.7.2.jar和Hibernate框架自带的ntlr2.7.7.jar冲突了故只要删除低版本的antlr2.7.2.jar就行,但是antlr2.7.2.jar是Struts2框架自带的,所以删除后重新编译还会再次出现,异常还是解决不了。

    具体如下:
    Window-->Preferences-->MyEclipse-->Project Libraries-->Struts 2.1 Libraries-->Core 你就会看到antlr2.7.2.jar,此时先勾选Enable advanced configuration,再去取消勾选antlr2.7.2.jar。

    再去Workspace.metadata.me_tcat7webapps项目名WEB-INFlib下强制删掉antlr2.7.2,重启Tomcat,异常就不再出现。

    两者缺一不可。


     2.

    hibernate 中 Provided id of the wrong type for class 异常
    
    HTTP Status 500 - Provided id of the wrong type for class com.s_football.pojo.UserBean. Expected: class java.lang.Integer, got class java.lang.String; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.s_football.pojo.UserBean. Expected: class java.lang.Integer, got class java.lang.String
    

      

    收集资料后发现:在HibernateTemplate中的get方法仅仅可以查找主键,不可以查找其他字段。其实是自己没有考虑好,在开始的时候自己还有过这样的疑问:get来查找是怎么对应字段,而且查找出来只是单个的,并不是个List。但是没有多想,现在用get来查找其他字段就抛出了了这个异常。
    其实看到这个异常就可以知道,肯定是类型错误,像我这个就是String类型转int类型了(在使用get方法中)。
    所以,检查一下类型匹配就可以解决了,包括是不是也用get方法查找其他字段了(其实也是类型匹配的问题)


  • 相关阅读:
    linux apache + mysql +php no-yum
    linux apache + mysql +php
    1像素border
    vue-router配置
    错误Cannot find module 'stylus'
    高仿饿了么mock本地数据
    vue2.0高仿饿了么better-scroll
    npm 常用命令
    Gulp工具常用插件
    git总结
  • 原文地址:https://www.cnblogs.com/Roni-i/p/10171888.html
Copyright © 2020-2023  润新知