开发者

Page Encoding in JSP

What's the best way to specify page encoding - using a page directive like this?

<%@ page language="java" contentType="text/html; c开发者_如何转开发harset=UTF-8" pageEncoding="UTF-8"%>

Or should I directly put it in a meta tag?

<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>

Eclipse by default uses both, so does that mean I need both?


You don't need both. Actually, <%@ page pageEncoding="utf-8" %> suffices.


I would think that you need both, don't you? My guess is that the page directive tells the Container to compile the JSP using the specified encoding and the meta tag tells the browser how the page is encoded.


In case you need to use UTF-8, you also need to set the charset for your connection url as well as the request and response.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜