JSP标签的字符集
关于JSP标签字符集的简单问题。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="custom" %>
<custom:mytag> </custom:mytag>
mytag
是简单的 .tag
文件,位于 WEB-INF/tags
中。 eclipse中该文件的字符集是UTF-8。由于某种原因,UTF-8 符号无法正确显示。
这仅影响包含标签,包含的另一个 jsp-s 显示正常
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
放置在标记文件中的
<%@tag pageEncoding="UTF-8"%>
会有所帮助。标签指令属性类似于其
page
对应项。<%@tag pageEncoding="UTF-8"%>
placed in your tag file will help.Tag directive attributes resemble ones of its
page
counterpart.就我而言,问题在于 pageEncoding 属性的声明顺序。我发现 pageEncoding 属性必须是 @tag 指令之后声明的第一个属性。
不正确:
<%@tag description="some description" pageEncoding="UTF-8"%>
正确:
< ;%@tag pageEncoding="UTF-8" description="一些描述"%>
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"%>