我试图通过使用WEB-INF目录中web.xml文件中的配置来呈现para值,但我只是The default user from the servlet config is:
呈现(没有web.xml文件的parm值) )。有人可以解释我的错误在哪里吗?
initpage.jps
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
The default user from the servlet config is:
<%getServletConfig().getInitParameter("defaultUser");%>
</body>
</html>
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SimpleServletProject</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>InitJSP</servlet-name>
<jsp-file>/initpage.jsp</jsp-file>
<init-param>
<param-name>defaultUser</param-name>
<param-value>Default User Name</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>InitJSP</servlet-name>
<url-pattern>initpage.jsp</url-pattern>
</servlet-mapping>
</web-app>