Charset of JSP tags

╄→гoц情女王★ 提交于 2019-12-05 01:28:56

问题


Simple question about charset of JSP tags.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib  tagdir="/WEB-INF/tags" prefix="custom" %>
<custom:mytag>  </custom:mytag>

mytag is simple .tag file located in WEB-INF/tags. Charset of this file in eclipse is UTF-8. For some reason UTF-8 symbols do not display properly.

This affect only including tags, another jsp-s that was included display fine


回答1:


<%@tag pageEncoding="UTF-8"%> placed in your tag file will help.

Tag directive attributes resemble ones of its page counterpart.




回答2:


In my case, the problem was the order of declaration of pageEncoding attribute. I figured out that pageEncoding attribute must be the first attribute declared right after @tag directive.

Incorrect: <%@tag description="some description" pageEncoding="UTF-8"%>

Correct: <%@tag pageEncoding="UTF-8" description="some description"%>



来源:https://stackoverflow.com/questions/9242682/charset-of-jsp-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!