我只是在玩弄JSP。我只想测试一些的东西,但是我做不到。每次使用都会出错。即使只有这个,我也会出错:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<jsp:useBean id="mybean" class="Users" scope="session" >
<jsp:setProperty name="mybean" property="name" value="Hello world" />
</jsp:useBean>
</body>
</html>
没有使用
<jsp:useBean>
时,它可以正常运行。但是使用<jsp:useBean>
时,会出现以下错误:Servlet.service() for servlet [jsp] in context with path [/JSPTest] threw exception [Unable to compile class for JSP:
An error occurred at line: 10 in the jsp file: /index.jsp
Users cannot be resolved to a type
7: <title>Insert title here</title>
8: </head>
9: <body>
10: <jsp:useBean id="mybean" class="Users" scope="session" >
11: <jsp:setProperty name="mybean" property="name" value="Hello world" />
12: </jsp:useBean>
13: </body>
我正在使用 Eclipse、Tomcat 7.0.23 和 Java 1.7.0_01。
有什么想法吗?
PS:我不得不将端口 8xxx 更改为 9xxx,因为 Oracle 数据库正在使用标准的 8xxx。但这可能不是问题的原因。
<jsp:useBean>
是其一部分,因为它基本上只绑定了M和V而没有C)。 Scriptlets已经被弃用了将近十年。另请参阅https://dev59.com/13A75IYBdhLWcg3wqK10和http://stackoverflow.com/tags/jsp/info。 - BalusC