<%-- Document : configTest2 Created on : 2020-4-11, 21:49:46 Author : Administrator --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content= "text / html; charset = UTF-8" > < title > Test config built-in object </ title > </ head > < body > <!- output the configuration parameter named name of this JSP- > name configuration parameter value: <% = config.getInitParameter ( " name " ) %> < br /> <! - the output of the JSP configuration parameter named age -> age configuration parameter values: <% = config.getInitParameter ( " age " ) %> </ body > </html>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> <!-- 配置第一个参数:driver --> <context-param> <param-name>driver</param-name> <param-value>com.mysql.cj.jdbc.Driver </ param-value > </ context-param > <!- Configure the second parameter: url- > < context-param > < param-name > url </ param- name > < param-value > jdbc: mysql: // localhost: 3306 / taobao </ param-value > </ context-param > <!- Configure the third parameter: user- > < context-param > < param-name > user </ param-name > <param-value>root</param-value> </context-param> <!-- 配置第四个参数:pass --> <context-param> <param-name>pass</param-name> <param-value>admin</param-value> </context-param> <servlet> <!-- 指定Servlet名字 --> <servlet-name>config</servlet-name> <!>--Specify which JSP page is configured as a Servlet- < jsp-file > /configTest2.jsp </ jsp-file > <!- Configure the parameter named name, the value is crazyit.org- > < init-param > < param-name > name </ param-name > < param-value > crazyit.org </ param-value > </ init-param > <!- Configure a parameter named age with a value of 30- > < init-param > < param-name > age < / param-name > <param-value>30</param-value> </init-param> </servlet> <servlet-mapping> <!-- 指定将config Servlet配置到/config URL--> <servlet-name>config</servlet-name> <url-pattern>/config</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>