这个异常是啥情况

来源:1-11 Servlet获取表单数据

慕粉3974963

2017-09-10 16:57

错误提示:

org.apache.jasper.JasperException: file:/dologin.jsp(13,4) jsp:getProperty for bean with name 'username'. Name was not previously introduced as per JSP.5.3

at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1249)

at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1131)

at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)

at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444)

at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450)

at org.apache.jasper.compiler.Node$Root.accept(Node.java:471)

at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)

at org.apache.jasper.compiler.Generator.generate(Generator.java:3652)

at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:252)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:333)

at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:394)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)

at servlet.loginServlet.doPost(loginServlet.java:75)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)


org.apache.jasper.JasperException: file:/dologin.jsp(13,4) jsp:getProperty for bean with name 'username'. Name was not previously introduced as per JSP.5.3

at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1249)

at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1131)

at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)

at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444)

at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450)

at org.apache.jasper.compiler.Node$Root.accept(Node.java:471)

at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)

at org.apache.jasper.compiler.Generator.generate(Generator.java:3652)

at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:252)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:333)

at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:394)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)

at servlet.loginServlet.doPost(loginServlet.java:75)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)

dologin.jsp代码如下

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ page import="user.Users,java.text.*" %>

<!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>dologin</title>

</head>

<body>

<h1>注册信息</h1>

<jsp:useBean id="regUser" class="user.Users" scope="session"/>

用户名:<jsp:getProperty property="regUser" name="username"/><br>

密码:<jsp:getProperty property="regUser" name="password"/><br>

邮箱:<jsp:getProperty property="regUser" name="email"/><br>

性别:<jsp:getProperty property="regUser" name="gender"/><br>

生日:<%

SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");

String date = sdf.format(regUser.getBirthday());

%>

<%=date %>

自我介绍:<jsp:getProperty property="regUser" name="instroduce"/><br>

是否接受协议:<jsp:getProperty property="regUser" name="flag"/><br>

爱好:<%

String[] hobby = regUser.getHobby();

for(String h : hobby){

%>

<%=h %>&nbsp;&nbsp;

<%

}

%>

</body>

</html>


写回答 关注

1回答

  • 瞬間悸動
    2017-09-11 21:28:43
    已采纳

    你写错了,<jsp:getProperty property="regUser" name="username"/><br>.name的值应该是useBean里的id,property是要获取值的属性名

    慕粉3974...

    非常感谢!

    2017-09-12 21:20:03

    共 1 条回复 >

JAVA遇见HTML——Servlet篇

本门课程在JSP课程的基础上,深入介绍Servlet的基础知识

160613 学习 · 1029 问题

查看课程

相似问题