lihfxy 2015-11-27 03:15 采纳率: 100%
浏览 3599
已采纳

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,到底是哪里出了问题呢?

  • 写回答

5条回答 默认 最新

  • GrowingDarker 2015-11-27 04:18
    关注

    倒数第二行 , 查看留言板 几个字 左边的 a 标签内部的链接地址错误 , 你把 . 写成了 ,

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘