似乎在ActionForm里面也有个setServlet方法,你重写这个方法
import javax.servlet.ServletContext;
import org.apache.struts.action.ActionServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class UserForm extends ActionForm {
private UserService service;
@Override
public void setServlet(ActionServlet servlet) {
ServletContext context = servlet.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
UserService service = (UserService)ctx.getBean("userService");
super.setServlet(servlet);
}
get...set...
......
}
import javax.servlet.ServletContext;
import org.apache.struts.action.ActionServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class UserForm extends ActionForm {
private UserService service;
@Override
public void setServlet(ActionServlet servlet) {
ServletContext context = servlet.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
UserService service = (UserService)ctx.getBean("userService");
super.setServlet(servlet);
}
get...set...
......
}
解决方案 »
- MySql 在Myeclipse 中 Structs ,Ibats ,Spring 结构下 加载关键字
- 电子商务网
- 开发企业管理软件用什么技术好?
- 紧急求救,过滤器配置问题报错:The requested resource (/student/) is not available
- JDK1.5下面的RMI怎么用的啊,现在好象不要stub那些东西了,知道的进来下吧
- struts高手请过来看看啊。。在线等啊。。。碰到一个怪问题。。。
- 哪个高手能帮忙做一下,送高分,在线等呀,救命呀
- 关于JBuilder9+ Struts1.1的问题,请大家务必指教一二!
- javaee并发修改异常
- Hibernate中使用原生SQL,那配置的方言还起作用嘛?
- 关于jsp/servlet中类变量线程安全性的一点疑问?
- Hibernate调用MSSQL存储过程问题
import javax.servlet.ServletContext;
import org.apache.struts.action.ActionServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class UserForm extends ActionForm {
private UserService service;
@Override
public void setServlet(ActionServlet servlet) {
ServletContext context = servlet.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
this.service = (UserService)ctx.getBean("userService");
super.setServlet(servlet);
}
get...set...
......
}