這是我的代碼:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.util.*"%>
<HTML><BODY>
<%! Vector v=new Vector();
ServletContext application;
synchronized void sendMessage(String s){
application=getServletContext();
v.add(s);
application.setAttribute("Mess",v);
}
%>
<% String name=request.getParameter("peopleName");
String title=request.getParameter("Title");
String messages=request.getParameter("messages");
if(name==null){
name="guest"+(int)(Math.random()*10000);
}
if(title==null){
title="無標題";
}
if(messages==null){
messages="無信息";
String time=new Date().toString();
String s="#"+name+"#"+title+"#"+time+"#"+messages+"#";
sendMessage(s);
out.print("您的信息已經提交!");
%>
<A href="submit.jsp">返回
<A href="showMessage,jsp">查看留言板
</BODY></HTML>
在浏覽器中用localhost:8080打開後報錯,雖然有錯誤提示,但我不太清楚該怎麼改,以下是錯誤信息:
An error occurred at line: 4 in the jsp file: /messagePane.jsp
Vector cannot be resolved to a type
1: <%@ page contentType="text/html;charset=GB2312" %>
2: <%@ page import="java.ytil.*"%>
3: <HTML><BODY>
4: <%! Vector v=new Vector();
5: ServletContext application;
6: synchronized void sendMessage(String s){
7: application=getServletContext();
An error occurred at line: 8 in the jsp file: /messagePane.jsp
v cannot be resolved
An error occurred at line: 9 in the jsp file: /messagePane.jsp
v cannot be resolved to a variable
5: ServletContext application;
6: synchronized void sendMessage(String s){
7: application=getServletContext();
8: v.add(s);
9: application.setAttribute("Mess",v);
10: }
11: %>
An error occurred at line: 23 in the jsp file: /messagePane.jsp
Date cannot be resolved to a type
20: }
21: if(messages==null){
22: messages="無信息";
23: String time=new Date().toString();
24: String s="#"+name+"#"+title+"#"+time+"#"+messages+"#";
25: sendMessage(s);
26: out.print("您的信息已經提交!");
感覺從語法上並沒有什麼錯,錯誤提示也都是can't be resolved,到底是哪裡出了問題呢?
倒數第二行 , 查看留言板 幾個字 左邊的 a 標簽內部的鏈接地址錯誤 , 你把 . 寫成了 ,