【发布时间】:2014-07-27 12:36:04
【问题描述】:
下面是我的servlet.xml。我需要添加以下节点
<bean id="myController2"class="com.restcontrollers.MyController2"></bean>
在运行时到这个 xml。 这可能吗?如果可以,怎么做?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.restcontrollers"/>
<bean id="myController1"class="com.restcontrollers.MyController1">
</bean>
<mvc:annotation-driven />
</beans>
我们将不胜感激任何形式的帮助。 提前致谢。
【问题讨论】:
-
你想要完成什么?根据您尝试做的事情,可能会有更好的可行解决方案
-
您可以添加该行,但不会重新读取配置。
-
感谢您的帮助。实际上我正在尝试在运行时加载新控制器。