问题
What I would like to avoid is specifying a page directive at the beginning of every JSP.
As I understand, without the following line, the default for the Content-Type for the page will be set to "text/html;charset=ISO-8859-1".
<%@ page contentType="text/html; charset=UTF-8" %>
Is there a configuration option that does the same thing without having to explicitly set the charset for every single JSP file in an application?
回答1:
You can add the following to web.xml
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
<default-content-type>text/html</default-content-type>
</jsp-property-group>
</jsp-config>
来源:https://stackoverflow.com/questions/22407500/set-the-default-encoding-to-utf-8-for-all-jsps-without-using-page-directives