这是我的代码:
<%@ 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 标签内部的链接地址错误 , 你把 . 写成了 ,
某个JSP内容如下,在Eclipse会出现JSP Problem如标题所示的javax.servlet.jsp.PageContext cannot be resolved to a type:
解決办法:把改为。
文章转自zzwell空间http://hi.baidu.com/vincent080928/blog/item/9fbbe18959b78f98a5c272f7.htm......
答案就在这里:JSP页面无故报错 javax.servlet.jsp.PageContext cannot be resolved to a type
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?
还有正数第二行,你引入库的代码, 你引入的 是 java.ytil.* 改为 java.util.*即可
有什么引用没写正确,好好检查下
没有引入Vector所在的包java.util.Vector。加上试试。