开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜