今天做個(gè)spring和struts的集成Demo,我用的是myeclipse6.5,導(dǎo)入spring框架和struts框架都相當(dāng)方便,一切就序后,開(kāi)tomcat,跑吧,相當(dāng)?shù)牟凰谝粋€(gè)鏈接就爆: servlet action is not available,什么意思啊,難道我的配置文件沒(méi)配對(duì)?檢查了沒(méi)天也沒(méi)發(fā)現(xiàn)什么問(wèn)題.
以下是我的struts 的struts-config.xml:
<struts-config>
<data-sources />
<form-beans />
<global-exceptions />
<global-forwards />

<action-mappings>
<action path="/hello" type="com.laxxx.struts.action.Hello">
<forward name="hello" path="/hello.jsp" />
</action>
</action-mappings>

<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />

<message-resources
parameter="com.laxxx.struts.ApplicationResources" />

<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>
</struts-config>
以下是spring的applicationContext.xml:
<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.5.xsd">

<bean name="/hello" class="com.laxxx.struts.action.Hello">

</bean>
</beans>
看了又看找了又找,還是沒(méi)看出問(wèn)題,把struts-config中關(guān)于spring兩段配置去掉后,單跑struts是沒(méi)問(wèn)題的,看來(lái)很有可能myeclipse沒(méi)把包導(dǎo)全啊,可能沒(méi)找到,發(fā)現(xiàn)好多人都中過(guò)此招,有些包沒(méi)找到spring的代理請(qǐng)求處理類或者是沒(méi)找到初始化spring上下文的插件類,這兩個(gè)類都在spring.jar中,于是把這個(gè)jar包放入lib目錄中去,重啟tomcat... ... 再點(diǎn),ok,終于到應(yīng)該去的地方了.
以下是我的struts 的struts-config.xml:

























以下是spring的applicationContext.xml:








看了又看找了又找,還是沒(méi)看出問(wèn)題,把struts-config中關(guān)于spring兩段配置去掉后,單跑struts是沒(méi)問(wèn)題的,看來(lái)很有可能myeclipse沒(méi)把包導(dǎo)全啊,可能沒(méi)找到,發(fā)現(xiàn)好多人都中過(guò)此招,有些包沒(méi)找到spring的代理請(qǐng)求處理類或者是沒(méi)找到初始化spring上下文的插件類,這兩個(gè)類都在spring.jar中,于是把這個(gè)jar包放入lib目錄中去,重啟tomcat... ... 再點(diǎn),ok,終于到應(yīng)該去的地方了.