为什么Struts2的Action中获取ServletActionContext.getPageContext()==null
packagecom.InteriorDesign.action;importjavax.servlet.ServletConfig;importjavax.servle...
package com.InteriorDesign.action;
import javax.servlet.ServletConfig;
import javax.servlet.jsp.PageContext;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
@Component("forwardAction")
public class ForwardAction extends ActionSupport {
private Logger logger=Logger.getLogger(ForwardAction.class);
public String execute(){
logger.info("============");
logger.info(ServletActionContext.getResponse()==null);
logger.info(ServletActionContext.getPageContext()==null);
logger.info(ServletActionContext.getPageContext().getServletConfig()==null);
return "success";
}
}
请问如何才能正常获取PageContext对象而不为空呢? 展开
import javax.servlet.ServletConfig;
import javax.servlet.jsp.PageContext;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
@Component("forwardAction")
public class ForwardAction extends ActionSupport {
private Logger logger=Logger.getLogger(ForwardAction.class);
public String execute(){
logger.info("============");
logger.info(ServletActionContext.getResponse()==null);
logger.info(ServletActionContext.getPageContext()==null);
logger.info(ServletActionContext.getPageContext().getServletConfig()==null);
return "success";
}
}
请问如何才能正常获取PageContext对象而不为空呢? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询