java_web/webapp/hello.jsp
2024-11-26 15:35:29 +08:00

33 lines
982 B
Plaintext

<%-- <%@ 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>A Simple JSP page</title> -->
<!-- </head> -->
<!-- <body> -->
<!-- <h3>Hello,World!</h3> -->
<!-- <font color="#0000ff"> -->
<%-- The time now is:<%=new java.util.Date()%> --%>
<!-- </font> -->
<!-- </body> -->
<!-- </html> -->
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page errorPage="errorHandler.jsp" %>
<html>
<body>
<%
String name = request.getParameter("name");
if (name == null) {
throw new RuntimeException("没有指定name 属性。");
} else {
// 将字符串name的字符编码转换为汉字编码
name = new String(name.getBytes("iso-8859-1"), "gb2312");
}
%>
Hello, <%= name %>
</body>
</html>