<%@ page language="java" contentType="text/html;charset=GBK" %>
<html>
<head>
<title>hello page</title>
</head>
<body>
<center>
<h1> <font size="30" color="red"> hello,welcome to visit this page....</font> </h1>
</center>
<%=application.getInitParameter("name") %><hr><br>
<%=application.getInitParameter("age") %><hr><br>
</body>
</html>
我的WEB-INF文件夹下的web.xml配置文件已经配置号了如下:<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <context-param>
<param-name>name</param-name>
<param-value>haodu</param-value>
</context-param>
<context-param>
<param-name>age</param-name>
<param-value>25<param-value>
</context-param>
</web-app>
是在jsp文件中为什么用application内置对象却读不出name和age参数值?
麻烦大家帮忙解决下,谢谢!web.xmlJava
<html>
<head>
<title>hello page</title>
</head>
<body>
<center>
<h1> <font size="30" color="red"> hello,welcome to visit this page....</font> </h1>
</center>
<%=application.getInitParameter("name") %><hr><br>
<%=application.getInitParameter("age") %><hr><br>
</body>
</html>
我的WEB-INF文件夹下的web.xml配置文件已经配置号了如下:<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <context-param>
<param-name>name</param-name>
<param-value>haodu</param-value>
</context-param>
<context-param>
<param-name>age</param-name>
<param-value>25<param-value>
</context-param>
</web-app>
是在jsp文件中为什么用application内置对象却读不出name和age参数值?
麻烦大家帮忙解决下,谢谢!web.xmlJava
另外,也穷举下看看有啥:
Enumeration enema = application.getInitParameterNames();
while(enema.hasMoreElements()){
String name=(String)enema.nextElement();
String value=application.getInitParameter(name);
System.out.println(name + "= " + value);
}避免是配置没有生效。