Struts1集成Spring2时要注意,如果要由Spring2管理Action的话,需要
在/WEB-INF下面建立文件action-servlet.xml文件,然后加入action对应的
<bean name="" class=""/>,其中name与<action>的path属性一致,此处不能id。
Spring1中可以放在默认的applicationContext.xml中,而Spring2须放到单独的action-servlet.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean name="/login" class="com.lxt008.struts.action.LoginAction"> </bean> </beans>