楼主,你的那个问题我也出现过,在struts-config.xml文件中不光要配置
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in> 还得 配置ACTION 的TYPE 具体是什么 我也记不清了,你可以通过快捷打出来
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in> 还得 配置ACTION 的TYPE 具体是什么 我也记不清了,你可以通过快捷打出来
这个找的是classes目录下的文件;不是/WEB-INF/applicationContext.xml 。还有 建议你看下struts提供的例子。
sprint的调用类:
package com.sbgl.util;import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;public class SpringHelper {
private static ThreadLocal<ApplicationContext> context = new ThreadLocal<ApplicationContext>(); private static Logger log = LogManager.getLogger(SpringHelper.class); public static void init() {
try {
log.info("Begin to init context.");
ApplicationContext _ctx = null;
_ctx = null;
setApplicationContext(_ctx);
} catch (Exception e) {
log.error(e);
} } public static Object getBean(String beanName) {
ApplicationContext ctx = getApplicationContext();
return ctx.getBean(beanName);
} public static void setApplicationContext(ApplicationContext ctx) {
context.set(ctx);
} public static ApplicationContext getApplicationContext() {
ApplicationContext ctx = (ApplicationContext) context.get();
if (ctx == null)
throw new RuntimeException("Web Application context load failed!");
return ctx;
}}
web.xml配置如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="classpath:applicationContext.xml" />
</plug-in>还有就是
<action attribute="cstServiceForm" name="cstServiceForm"
parameter="oper" path="/svrRpt" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="list" path="/jsp/~rept/ser.jsp" />
</action>
也要该还有你是不是把业务类和ACTION都注入到了SPREEN里边了