为了账号安全,请及时绑定邮箱和手机立即绑定

JSP学习中在使用useBean时,class报错。 cannot be resolved to a type

JSP学习中在使用useBean时,class报错。 cannot be resolved to a type

<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> <%@ page import="Math.Box" %> <% 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 'index.jsp' starting 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>    <jsp:useBean id="box" class="Math.Box" scope="page"></jsp:useBean>    <h1>普通方式显示javabeans</h1>   </body> </html>java代码package Math; public class Box { private int length; private int width; private int height; public Box() { } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public int getWidth() { return width; } public void setWidth(int width) { this.width = width; } public int getHeight() { return height; } public void setHeight(int height) { this.height = height; } }在useBean的class报错: cannot be resolved to a type强行运行报错Unable to compile class for JSP:The server encountered an internal error that prevented it from fulfilling this request.
查看完整描述

1 回答

已采纳
?
安静_天空

TA贡献11条经验 获得超3个赞

我运行了一下你的代码,把Math改个名字就可以正常运行~我想可能是math是一个java.util中的类,类式与关键字吧~

查看完整回答
1 反对 回复 2016-04-04
  • 1 回答
  • 0 关注
  • 2328 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信