<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java./xml/ns/javaee" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://java./xml/ns/javaee http://java./xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>Encoding2</param-name> <param-value>GBK</param-value> </context-param> <servlet> <servlet-name>Test</servlet-name> <servlet-class>day01.Test</servlet-class> <init-param> <param-name>Encoding</param-name> <param-value>UTF8</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Test</servlet-name> <url-pattern>/test</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>login.html</welcome-file> </welcome-file-list> </web-app> 在servlet中获取的方式: 1\ <servlet> <init-param> <param-name>Encoding</param-name> <param-value>UTF8</param-value> </init-param> </servlet> this.getServletConfig().getInitParameter("Encoding"); 2\ <context-param> <param-name>Encoding</param-name> <param-value>UTF8</param-value> </context-param> this.getServletContext().getInitParammeter("Encoding"); |
|