取得ServletContext 在jsp页面可以可以application取得,我现在code中,想直接取得当前请求的ServletContext咋做?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Servlet中// 获取ServletContextServletContext context = getServletContext();// 获取String userName = (String)context.getAttribute("USERNAME"); 在对应的Jsp中String userName = (String)application.getAttribute("USERNAME"); 谢谢回复!!你这压迫配置Servlet,好像Filter,Listenner也可以吧但是我不想配置任何东西!直接在取得 ,就像.net下的HttpContext.Current;取得一样的! jsp源码可供参考: private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();... pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext();... 谢谢 我刚才去看了 Servlet生成的源代码! ServletActionContext.getServletContext()这个? 发布后 获取文件路径 请问怎么用js获得页面元素的属性(class定义) BeanUtils跟Colone麻烦解释下 截取网站代码遇到问题 关于jsp中使用frame问题. 利用JAVA读取网页的一些疑问 远程网站访问本网站时怎么获得远程网站的域名? tomcat装不上怎么办?分不够可以多给! 有关javabean 刚接触javamail,高分问一些简单的问题 quartz部署时,报错 Javascript获取Id的值?
Servlet中// 获取ServletContextServletContext context = getServletContext();// 获取String userName = (String)context.getAttribute("USERNAME"); 在对应的Jsp中String userName = (String)application.getAttribute("USERNAME");
你这压迫配置Servlet,好像Filter,Listenner也可以吧
但是我不想配置任何东西!直接在取得 ,就像.net下的HttpContext.Current;取得一样的!
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
...
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
...
这个?