程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> jsp-JSP代碼運行報錯,cant be resolved

jsp-JSP代碼運行報錯,cant be resolved

編輯:編程綜合問答
JSP代碼運行報錯,can't be resolved

這是我的代碼:

<%@ 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 標簽內部的鏈接地址錯誤 , 你把 . 寫成了 ,

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved