新建的一个jsp页面如下,为什么结果是null?<%@ page language="java" import="java.util.*" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<% Servlet s = (Servlet)page; %>
<%=s.getServletConfig().getServletContext().getServletContextName()%>
</body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<% Servlet s = (Servlet)page; %>
<%=s.getServletConfig().getServletContext().getServletContextName()%>
</body>
</html>
解决方案 »
- 关于servlet返回的text/html格式信息的时候
- String解析
- char c; System.out.println("char [" + a.c + "]"); 为什么输出char [□]
- 分布式异构数据库
- 关于jsp中setattribute()、getattribute()的用法
- 求救:struts的token怎么使用
- spring jdbctemplate与hibernate共用一个DataSource?
- 严重: Catalina.stop: java.net.ConnectException: Connection refused 请问这个问题怎么解决?
- 请教一个EJB调试的问题,急急!
- 我的一级分类和二级分类有设置一对多多对一的关系,但是在查询到的一级分类中用容器注入的二级分类查询为空
- java 多线程实际应用的问题
- struts1.x问题
<%=s.getServletConfig().getServletContext().getServletContextName()%>
直接写为:《%=pageContext.getServletContext().getServletContextName()%>pageContext是jsp的内置对象,可以直接使用