[英]Spring 2.5 dispatcher.xml configuration, “can not set bean property 'methodNameResolver'” error
I am working on a legacy application. 我正在处理旧版应用程序。 It has a main controller, JobController which is extended from org.springframework.web.servlet.mvc.multiaction.MultiActionController.
它有一个主控制器JobController,它是从org.springframework.web.servlet.mvc.multiaction.MultiActionController扩展而来的。 This application was running previously (I don't know how) but currently during start-up I get an error related to methodNameResolver.
此应用程序以前在运行(我不知道如何运行),但是当前在启动过程中收到与methodNameResolver相关的错误。
The error says "Invalid property 'methodNameResolver' of bean class [packageName.JobController]: Bean property 'methodNameResolver' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?" 错误显示“ Bean类[packageName.JobController]的无效属性'methodNameResolver':Bean属性'methodNameResolver'是不可写的或具有无效的setter方法。setter的参数类型是否与getter的返回类型匹配?”
My dispatcher.xml is like below 我的dispatcher.xml如下所示
<bean class="packageName.JobController">
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/login.htm">hndLoginHTM</prop>
<prop key="/login.ajax">hndLoginAJAX</prop>
<prop key="/logout.ajax">hndLogoutAJAX</prop>
<prop key="/submit.data">hndSubmitData</prop>
<prop key="/get.log">hndGetLog</prop>
<prop key="/getJdbc.log">hndGetJdbcLog</prop>
<prop key="/vtInsert.deneme">vtInsertTest</prop>
</props>
</property>
</bean>
</property>
</bean>
When I replace "packageName.JobController" with "MultiActionController" then I do not get this error, however since MultiActionController is a spring class it does not include my methods (hndLoginHTM, hndLoginAJAX) so this causes a new error normally. 当我将“ packageName.JobController”替换为“ MultiActionController”时,我没有收到此错误,但是由于MultiActionController是spring类,它不包含我的方法(hndLoginHTM,hndLoginAJAX),因此通常会导致新的错误。
In summary, I thşnk that Spring does not understand that my controller is an instance of MultiActionController so it gives error to the property. 总而言之,我认为Spring不了解我的控制器是MultiActionController的实例,因此它给属性带来了错误。
I already attempted to write the bean definition in various ways but nothing worked. 我已经尝试过以各种方式编写bean定义,但是没有任何效果。 Any help will be appreciated.
任何帮助将不胜感激。
You may offer to upgrade the Spring version and use annotations.It is in our plans, but before doing that we need to make this version work and do some tests. 您可能会提供升级Spring版本并使用批注的功能,这已在我们的计划中,但在此之前,我们需要使此版本正常工作并进行一些测试。
Regards, Ferda 问候,费尔达
Although this kind of configuration was very common in legacy java applications (my internet search result says so), I could find no way to fix this exception. 尽管这种配置在旧版Java应用程序中非常普遍(我的互联网搜索结果如此),但我找不到解决此异常的方法。 I waited enough time I also could not get any suggestion to fix this.
我等待了足够的时间,也没有得到解决此问题的任何建议。
So, I changed my plan and upgraded the Spring version and changed the method mappings to annotations. 因此,我更改了计划并升级了Spring版本,并将方法映射更改为注释。 At this point I do not get this exception.
在这一点上,我没有得到这个例外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.