在给Javabean属性赋值时报错500
HTTP Status 500 – Internal Server Error
Type Exception Report
Message /FirstDemo.jsp (line: [10], column: [0]) The value for the useBean class attribute [java.Person] is invalid.
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: /FirstDemo.jsp (line: [10], column: [0]) The value for the useBean class attribute [java.Person] is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1383) org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1186) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2441) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2447) org.apache.jasper.compiler.Node$Root.accept(Node.java:470) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389) org.apache.jasper.compiler.Generator.generate(Generator.java:3667) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:257) org.apache.jasper.compiler.Compiler.compile(Compiler.java:385) org.apache.jasper.compiler.Compiler.compile(Compiler.java:362) org.apache.jasper.compiler.Compiler.compile(Compiler.java:346) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/9.0.8
下面是自己的代码部分:
<%-- Created by IntelliJ IDEA. User: lihao Date: 2018/7/29 Time: 20:13 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <jsp:useBean id="person" class="java.Person"/> <html> <head> <title>Title</title> </head> <body> <c:set target="${person}" property="password" value="1234"/> <c:set target="${person}" property="username" value="223"/> <c:out value="${person.username}"/> <c:out value="${person.password}"/> </body> </html>
package java; public class Person { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }