I use JspTag to load data from struts2+spring+hibernate,usually I load data from struts2+spring+hibernate using following code:
public class TestAction extends ActionSupport{
......
WebApplicationContextUtils.getRequiredWebApplicationContext().getBean("testDao");
}
It can run well under struts2+spring+hibernate.
Now I use JspTag using above code,like follows:
public class TestTag extends TagSupport{
public int doStartTag() throws JspException{
......
WebApplicationContextUtils.getRequiredWebApplicationContext().getBean("testDao");
}
This time when I run my TestTag,it raise following error:
Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
with this statement---> WebApplicationContextUtils.getRequiredWebApplicationContext().getBean("testDao");
My question is how to load data from struts2+spring+hibernate by using JspTag?
Any idea and source code will be appreciated!
Best regards,
Edward