此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【zhangsc】截止到2008-07-16 11:29:20的历史汇总数据(不包括此帖):
发帖的总数量:41                       发帖的总分数:1840                     每贴平均分数:44                       
回帖的总数量:21                       得分贴总数量:1                        回帖的得分率:4%                       
结贴的总数量:37                       结贴的总分数:1760                     
无满意结贴数:4                        无满意结贴分:190                      
未结的帖子数:4                        未结的总分数:80                       
结贴的百分比:90.24 %               结分的百分比:95.65 %                  
无满意结贴率:10.81 %               无满意结分率:10.80 %                  
值得尊敬

解决方案 »

  1.   

    可以从org.springframework.web.servlet.tags.RequestContextAwareTag继承,
    getRequestContext().getWebApplicationContext()可以得到spring的context
      

  2.   

    要有一块全局的context,通过它来得,就不会有问题,
    在启动的时候把它写进上下文
      

  3.   

    >>可以从org.springframework.web.servlet.tags.RequestContextAwareTag继承是指标签类可以这样写吗?
    public class TestTag extends org.springframework.web.servlet.tags.RequestContextAwareTag{
           ......
           WebApplicationContextUtils.getRequiredWebApplicationContext().getBean("testDao");
       }
    }
    能说得详细些吗?谢谢!
      

  4.   

    给你个例子public class XxxTag extends RequestContextAwareTag {
      //覆盖doStartTagInternal方法
      protected int doStartTagInternal() throws Exception {
          this.getRequestContext().getWebApplicationContext().getBean("beanName");
          
      }
    }
      

  5.   

    在标签中可以通过pageContext得到servletContext
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
    XxxService service = (XxxService)ctx.getBean("beanName");
      

  6.   

    用到什么jar包啊,我用了但报错,不知道什么原因org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/springframework/web/bind/EscapedErrors
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jsp.website.deptwebsite._0001.Index_jsp._jspService(Index_jsp.java:57)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.tiptech.platform.filters.SetEncodingFilter.doFilter(SetEncodingFilter.java:68)
      

  7.   

    我认为应该是这样的
    在 WebApplicationContextUtils.getRequiredWebApplicationContext().getBean("testDao");
    的getRequiredWebApplicationContext()的“()”中加入request.getSession().getServletContext()就可以了