日期:2014-05-16  浏览次数:20373 次

js中EL表达式使用(jsp中)
比如访问servlet set (request.setAttribute("xxx", "yy");
request.getRequestDispatcher("/2.jsp").forward(request, response)),然后跳转到http://localhost:8080/day05/set?name=Tom&age=30
然后可以通过以下代码获取相关数据,其实明白jsp翻译成的servlet代码,就会了然。JspWriter  out = pageContext.getout()。out.write("<script >");
<script type="text/javascript">
    	alert('${requestScope.xxx}');
    	alert('${xxx}');
    	alert('${param.age}');
    	alert('http://' + '${pageContext.request.serverName}' + ':' + '${pageContext.request.serverPort}' + '${pageContext.request.contextPath}' + '${pageContext.request.servletPath}');
    </script>