如何在javabean中往jsp的application内置对象中写入值?不使用struts2,纯javabean怎么用?不知什么函数获得application不使用struts2!也就不用struts2写的ActionContext和ServletActionContext更不是用jsp页面中的 <% application.setAttribute("","")%>

解决方案 »

  1.   

    ServletContext application = request.getSession().getServletContext();
    是这个吗?
      

  2.   

    request是什么类的??你这个还是直接在jsp页面中的 <%  %> 里头写的吧!!在java类中怎么可能这么写??
      

  3.   

    这样应该可以的吧:
    <jsp:useBean id="beanname" class="classname" socope="page">
    </jsp:useBean>
    <jsp:setProperty property="" name="beanname" value=""/>
    <%application.setAttribute(Object key, beanname.getProperty()); %>
      

  4.   


    您也不看帖我说的很明白,不要在jsp页面中写任何东西就是在java类里写。。
      

  5.   

    我是服了各位各种不靠谱的建议了正确方法是:让这个java类 extends HttpServlet 然后用this.getServletContext().getAttribute("xxx")