简体   繁体   English

Spring 2.5 dispatcher.xml配置,“无法设置bean属性'methodNameResolver'”错误

[英]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.

相关问题 如何在Spring XML元数据配置中为bean设置ServletContext属性 - How to set ServletContext property for a bean in Spring XML metadata configuration 如何使用Spring XML配置来设置包含特定类型的所有bean的列表的bean属性? - How can I use Spring XML configuration to set a bean property with list of all beans of a certain type? 使用来自其他bean属性的xml配置设置Spring bean属性 - Spring bean property set using xml configuration from other bean property 如何使用Spring配置将文本文件内容设置为bean属性 - How to set text file content to bean property using Spring configuration 为什么不能在春天将bean的id设置为属性 - why can not set id of a bean as property in spring 在 Spring Boot 中使用 @Bean 配置设置类属性的默认值 - Set default value of class property with @Bean configuration in Spring Boot 在web.xml中添加spring-dispatcher-servlet.xml配置时出现错误 - Getting error when adding spring-dispatcher-servlet.xml configuration in web.xml can spring容器XML配置引用使用另一个bean&#39;property - can spring container XML config reference use another bean'property 为什么我不能将用@Service注释的bean注入到spring-security.xml配置文件中声明的bean中? - Why I can't inject this bean annoted with @Service into a bean declared into the spring-security.xml configuration file? Spring @Controller和自定义MethodNameResolver - Spring @Controller and custom MethodNameResolver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM