在做ssh集成时 在action中getWebApplicationContext()这个方法怎么没有类或对象调用就直接写,这语法对不?
下面是action中的部分代码,代码运行没错
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionForward forward = null;

String name = request.getParameter("name");

String password = request.getParameter("password");

try{
//此行
biz = (IPersonBiz) getWebApplicationContext().getBean("dypersonbiz");

Person person = biz.login(name, password);

if(person != null)
                              ............

解决方案 »

  1.   

    你这代码又不全。 这个action继承了什么?
      

  2.   

    哦忘了这个public class LoginAction extends MappingDispatchActionSupport
      

  3.   

    这代码是个老师写的 当时没注意这地方 他似乎也没说 现在就是不明白为啥方法直接就用了
    在web.xml中这个 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext.xml
    </param-value>
       </context-param>
         <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>