首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

java.lang.NoSuchMethodException: $Proxy13.get()帮忙看看。解决方法

2012-03-30 
java.lang.NoSuchMethodException: $Proxy13.get()帮忙看看。。struts的配置文件XML code?xml version1.0

java.lang.NoSuchMethodException: $Proxy13.get()帮忙看看。。
struts的配置文件

XML code
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts>    <constant name="struts.i18n.encoding" value="gbk" />    <constant name="struts.objectFactory" value="spring" />    <package name="default" namespace="/admin" extends="struts-default">        <action name="putInsert" class="purveryAction"            method="Insert">            <result name="success">yes.html</result>            <result name="error">no.jsp</result>        </action>        <action name="getAll" class="purveryAction" method="get">            <result name="success">yes.jsp</result>            <result name="error">no.jsp</result>        </action>        <action name="getOne" class="purveryAction" method="get">            <result name="success">yes.jsp</result>            <result name="error">no.jsp</result>        </action>    </package></struts>   

spring 的配置文件
XML code
    <bean id="sessionFactory"        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">        <property name="configLocation" value="classpath:hibernate.cfg.xml">        </property>    </bean>    <bean id="txManager"        class="org.springframework.orm.hibernate3.HibernateTransactionManager">        <property name="sessionFactory" ref="sessionFactory" />    </bean>    <tx:advice id="txAdvice" transaction-manager="txManager">        <tx:attributes>            <tx:method name="get*" propagation="REQUIRED" read-only="true" />            <tx:method name="find*" propagation="REQUIRED" read-only="true" />            <tx:method name="search*" propagation="REQUIRED" read-only="true" />            <tx:method name="query*" propagation="REQUIRED" read-only="true" />            <tx:method name="add*" propagation="REQUIRED" />            <tx:method name="submit*" propagation="REQUIRED" />            <tx:method name="save*" propagation="REQUIRED" />            <tx:method name="insert*" propagation="REQUIRED" />            <tx:method name="del*" propagation="REQUIRED" />            <tx:method name="remove*" propagation="REQUIRED" />            <tx:method name="update*" propagation="REQUIRED" />            <tx:method name="modify*" propagation="REQUIRED" />            <tx:method name="check*" propagation="REQUIRED" />            <tx:method name="do*" propagation="REQUIRED" />            <tx:method name="*" propagation="REQUIRED" read-only="true" />        </tx:attributes>    </tx:advice>    <aop:config>        <aop:pointcut id="serviceMethod" expression="execution(* org.benz.action.*.*(..))" />        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />    </aop:config>    <bean id="purveryDao" class="org.benz.dao.impl.PurveyDaoImpl">        <property name="sessionFactory" ref="sessionFactory"></property>    </bean>    <bean id="purveryBiz" class="org.benz.biz.impl.PurveryBizImpl">        <property name="purdao" ref="purveryDao"></property>    </bean>    <bean id="purveryAction" class="org.benz.action.Purveyactionfrom">        <property name="purveryBiz" ref="purveryBiz"></property>    </bean></beans> 


action的代码
Java code
                     public String Insert() {            //将页面填写的省,市,区,详细地址合并成送货地址            this.purvey.setProvinces(this.getCity()+","+this.getRegion());            String str=purveryBiz.insert(purvey);            if(str =="插入成功"){                return SUCCESS;            }else{            return ERROR;        }    }    public String update(){        String ret =purveryBiz.updateById(purvey);        if(ret =="修改成功"){            return SUCCESS;        }        return ERROR;            }    public String get(){        List<Purvey> list = purveryBiz.getAll();        if(list != null){            ActionContext ac = ActionContext.getContext();            ac.getSession().put("supplierList", list);            return SUCCESS;        }else{            return ERROR;        }    }    public String getByTrading(){        Purvey pu = this.purveryBiz.getByTrading(this.getTrading());        if(pu != null){            ActionContext ac = ActionContext.getContext();            ac.getSession().put("purvey", pu);            return SUCCESS;        }else        {            return INPUT;        }    }        }

页面的代码:
HTML code
  <s:form action="putInsert" method="post">            <table>                <tr>                    <td colspan="4" class="subtitle">                        供货商信息                    </td>                </tr>                <tbody>                    <tr>                        <th style="width: 15%;">                            <span class="warning">*</span>供货商代码:                        </th>                        <td>                            <input id="Text2" type="text" name="purvey.trading" class="inputText" />                        </td>                        <th style="width: 15%;">                            <span class="warning">*</span>中文名称:                        </th>                        <td>                            <input id="Text26" name="purvey.chname" type="text" class="inputText" />                        </td>                    </tr>                    <tr>                        <th style="width: 300px;">                            <span class="warning">*</span>英文名称:                        </th>                        <td>                            <input id="Text27" type="text" name="purvey.englishname" class="inputText" />                        </td>                        <th style="width: 300px;">                            <span class="warning">*</span>网址:                        </th>                        <td>                            <input id="Text30" type="text" name="purvey.work" class="inputText" />                        </td>                    </tr>                    <tr>                        <th style="width: 300px;">                            <span class="warning">*</span>联系人:                        </th>                        <td>                            <input id="c_magazineId" type="text" name="purvey.linkman" class="inputText" />                        </td>                        <th style="width: 300px;">                            <span class="warning">*</span>联系电话:                        </th>                        <td>                            <input id="Text28" type="text" name="purvey.phone" class="inputText" />                        </td>                    </tr>                    <tr>                        <th>                            <span class="warning">*</span>省市:                        </th>                        <td>                          国家 <input type="text" id="country" name="purvey.country">                           省<input type="text" id="sheng" name="city">                           市 <input type="text" id="shi" name="region">                        </td>                        <th>                            <span class="warning">*</span>详细地址:                        </th>                        <td>                            <input id="Text1" type="text" class="inputText" name="purvey.address"/>                        </td>                    </tr>                    <tr>                        <th>                            <span class="warning">*</span>邮政编码:                        </th>                        <td>                            <input id="Text3" type="text" name="purvey.mail" class="inputText" />                        </td>                        <th>                            <span class="warning">*</span>企业简称:                        </th>                        <td>                            <input id="Text4" type="text" name="purvey.projectname" class="inputText" />                        </td>                    </tr>                    <tr>                        <th>                            <span class="warning">*</span>开户银行:                        </th>                        <td>                            <input id="Text5" type="text" name="purvey.bank" class="inputText" />                        </td>                        <th>                            <span class="warning">*</span>账号:                        </th>                        <td>                            <input id="Text6" type="text" name="purvey.accounts" class="inputText" />                        </td>                    </tr>                    <tr>                        <th>                            <span class="warning">*</span>收款单位:                        </th>                        <td>                            <input id="Text7" type="text" name="purvey.gatheringunit" class="inputText" />                        </td>                        <th>                            <span class="warning">*</span>付款条件:                        </th>                        <td>                            <input id="Text8" type="text" name="purvey.payment" class="inputText" />                        </td>                    </tr>                    <tr>                        <th>                            备注:                        </th>                        <td colspan="3">                            <textarea rows="5" style="width: 100%;" name="purvey.remark"></textarea>                        </td>                    </tr>                </tbody>                <tr>                    <td colspan="6" class="toolbar">                        <input type="submit" class="inputButton" value="确定"  />                        &nbsp;                        <input type="button" class="inputButton" value="取消" onclick="" />                    </td>                </tr>            </table>            </s:form>  



报错。:
java.lang.NoSuchMethodException: $Proxy13.get()
java.lang.Class.getMethod(Class.java:1605)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)


[解决办法]
把错误都贴出来!!!
[解决办法]
楼主。你看下Action的介绍吧。。你在Action中的这些方法是怎么样在HTML中被引的。
在ACTION中有默认的post.get.或是service方法。
或是在调用的时候用 <s:form action="putInsert!Insert" method="post">叹号后跟方法名来对应相对的方法。
像你这么写的话ACTION会自动调用ACTION中的post()或是service()方法。但你的ACTION中没有写这样的方法。所以会报错
[解决办法]

aop:config 加上 proxy-target-class="true" 试试

<aop:config proxy-target-class="true">

原因暂不解释
[解决办法]
public String insert()
方法名小写
[解决办法]
是木有getter和setter把。。

<bean id="purveryBiz" class="org.benz.biz.impl.PurveryBizImpl">
<property name="purdao" ref="purveryDao"></property>
</bean>
<bean id="purveryAction" class="org.benz.action.Purveyactionfrom">
<property name="purveryBiz" ref="purveryBiz"></property>
</bean>

org.benz.biz.impl.PurveryBizImpl里要有purdao的getter setter
org.benz.action.Purveyactionfrom里要有purveryBiz的getter setter
[解决办法]
探讨
引用:
aop:config 加上 proxy-target-class="true" 试试

<aop:config proxy-target-class="true">

原因暂不解释

加上这句话后控制台报错了,

org.springframework.dao.InvalidDataAccessApiUsageException: W……

[解决办法]
探讨
引用:

引用:
引用:
aop:config 加上 proxy-target-class="true" 试试

<aop:config proxy-target-class="true">

原因暂不解释

加上这句话后控制台报错了,

org.sprin……

[解决办法]
加了<aop:config proxy-target-class="true">会使用cglib创建代理,他直接创建目标对象的子类对象,你在action写的那些方法被代理子类对象继承下来了,所以不会报NoSuchMethodException了

热点排行