首先在web.xml进行配置:
<servlet-name>TestServlet</servlet-name>
<servlet-class>test.TestServlet</servlet-class>
<init-param>
<param-name>charset</param-name>
<param-value>utf-8</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/servlet/TestServlet</url-pattern>
</servlet-mapping>
然后再serlvet进行取得:
String MyCharset = getInitParameter("charset");