Setting character encoding in EL way
How can we achieve following in JSTL -
<% response.setCharacterEncoding("UTF-8"); %>
I know we can refer to response object as below but how we can we call setter m开发者_StackOverflow中文版ethod?
${pageContext.response}
Thanks.
That's supposed to be done by the following line in top of your JSP:
<%@page pageEncoding="UTF-8" %>
Or, if you want to apply this on all JSPs, add the following to your web.xml
:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
See also:
- Unicode - How to get the characters right? - JSP/Servlet response
精彩评论