在JSP中,pageEncoding="ISO-8859-1"(英文)可以改为pageEncoding="UTF-8"(中英文兼容),<% ……%>的内容是JAVA代码不会被显示
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page import="java.util.Date"%> <%@ page import="java.text.SimpleDateFormat"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP Time page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% Date date=new Date(); SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String today=df.format(date); %> 当前时间为:<%=today%> </body> </html>
时间: 2024-10-25 21:44:04