為什么我的<jsp:useBean ......>中的class報錯。Unable to compile class for JSP:
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; } }
JSP中:
<%@?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>
它在useBean的class報錯。Unable to compile class for JSP:
2016-03-26
首先,包的名稱一般以小寫字母開頭
其次。Math是java的關(guān)鍵字不能用于命名
2016-03-26