eclipse开发jsp,网页出现乱码

来源:互联网 发布:淘宝开店银行卡验证 编辑:程序博客网 时间:2024/05/06 18:46
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Insert title here</title>
</head>
<body>
jsp表达式<%= "hello world" %>
<br/>
<%!
String str = "hello world";
%>
<% 
//String str = "hello world";
out.println(str);
%>
</body>

</html>


第一次用的时候,eclipse 的jsp这边的charset都是设置的别的格式。所以得先把默认的代码改了,都改成utf-8。

但是这样还是不行。还得windows->preference->general->content types->text->jsp:

接着改一下最下面的default encoding 就好了。

0 0