zoukankan      html  css  js  c++  java
  • There is no getter for property named 'notice' in 'class com.game.domain.Notices'

    在插入数据时报错:There is no getter for property named 'notice' in 'class com.game.domain.Notices'

    四月 11, 2018 10:49:07 下午 org.apache.catalina.core.StandardWrapperValve invoke
    严重: Servlet.service() for servlet [springmvc] in context with path [/SpringDemo] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'notice' in 'class com.game.domain.Notices'] with root cause
    org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'notice' in 'class com.game.domain.Notices'
        at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:419)
        at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164)
        at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162)
        at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49)
        at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122)
        at org.apache.ibatis.reflection.MetaObject.metaObjectForProperty(MetaObject.java:145)
        at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:115)
        at org.apache.ibatis.executor.BaseExecutor.createCacheKey(BaseExecutor.java:219)
        at org.apache.ibatis.executor.CachingExecutor.createCacheKey(CachingExecutor.java:146)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    1. 数据库表

    2. Notices.java

    public class Notices implements Serializable{
        private Integer noticeID;
        private String noticeName;
        private String noticeContent;
        
        //setter and getter
    
    }

    3. SQL语句

    public String insertNotice(final Notices notice){
                
                return new SQL(){
                    {
                        INSERT_INTO("notices");
                        if(notice.getNoticeName() != null && !notice.getNoticeName().equals("")){
                            VALUES("noticeName", "#{notice.noticeName}");//notice.noticeName改成noticeName
                        }
                        if(notice.getNoticeContent() != null && !notice.getNoticeContent().equals("")){
                            VALUES("noticeContent", "#{notice.noticeContent}");//notice.noticeContent改成noticeContent
                        }
                    }
                }.toString();
            }

    原因:#{noticeContent}应该是取Notices的属性值,而不是取当前notice的属性值

  • 相关阅读:
    JQuery Ajax调用asp.net后台方法
    擦亮自己的眼睛去看SQLServer之简单Insert
    擦亮自己的眼睛去看SQLServer之简单Select
    SQL Server CONVERT() 函数
    给reporting services加个条件型的格式 (轉)
    优化SQL语句:in 和not in的替代方案
    技术不如你,但老板就是赏识他,为什么?
    LINQ to SQL活学活用(1):这要打破旧观念(轉)
    [续] MATLAB 混合编程——下篇:调用其它编程语言
    [精] MATLAB 混合编程——上篇:被其它编程语言调用
  • 原文地址:https://www.cnblogs.com/zeroingToOne/p/8799305.html
Copyright © 2011-2022 走看看