close
In some cases
當client尚未發出http request給
com.opensymphony.webwork.dispatcher.ServletDispatcher之前
webwork似乎尚未initial
因此操作ServletActionContext裡的方法經常有null之類的錯誤
例如我們會採用listener在web ap server start時
將property載入並set進application
再寫個SECSystemUtil class 提供static方法來存取application中的property
static {
logger = Logger.getLogger("sec");
context = ServletActionContext.getServletContext();
login_prop = (Properties) context.getAttribute("login_pram");
system_prop = (Properties) context.getAttribute("system_pram");
}
但假如在webwork尚未initial前,用servlet or jsp去call SECSystemUtil
則ServletActionContext.getServletContext()會產生錯誤
所以要在call SECSystemUtil 前先set一些東東 (see sec project RateQuery)
public class RateQuery extends HttpServlet{
public void init(ServletConfig config){
ServletActionContext.setServletContext(config.getServletContext());
....
}
}
或是在jsp中(see myskype top.inc)
com.opensymphony.webwork.ServletActionContext.setRequest(request);
當client尚未發出http request給
com.opensymphony.webwork.dispatcher.ServletDispatcher之前
webwork似乎尚未initial
因此操作ServletActionContext裡的方法經常有null之類的錯誤
例如我們會採用listener在web ap server start時
將property載入並set進application
再寫個SECSystemUtil class 提供static方法來存取application中的property
static {
logger = Logger.getLogger("sec");
context = ServletActionContext.getServletContext();
login_prop = (Properties) context.getAttribute("login_pram");
system_prop = (Properties) context.getAttribute("system_pram");
}
但假如在webwork尚未initial前,用servlet or jsp去call SECSystemUtil
則ServletActionContext.getServletContext()會產生錯誤
所以要在call SECSystemUtil 前先set一些東東 (see sec project RateQuery)
public class RateQuery extends HttpServlet{
public void init(ServletConfig config){
ServletActionContext.setServletContext(config.getServletContext());
....
}
}
或是在jsp中(see myskype top.inc)
com.opensymphony.webwork.ServletActionContext.setRequest(request);
全站熱搜
留言列表