Java 为什么我会得到org.apache.jasper.jaspereException?

Java 为什么我会得到org.apache.jasper.jaspereException?,java,jsp,jakarta-ee,servlets,Java,Jsp,Jakarta Ee,Servlets,当我运行以下servlet时: import javax.servlet.*; import javax.servlet.http.*; import java.io.IOException; public class Controller extends HttpServlet { @Override public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,Se

当我运行以下servlet时:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class Controller extends HttpServlet {
@Override
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
    Bean bean = new Bean(); 
    bean.setName("Suhail Gupta");
    request.setAttribute("Name", bean);
    RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
    rd.forward(request, response);
  }
}
例外情况:

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: PWC6054: Cannot find any information on property 'Name' in a bean of type 'Bean'

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
是生成的。我不明白为什么会这样

下面是Bean类:

这是
index.jsp
页面:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
    <jsp:useBean id="name" class="Bean" scope="request" />
    Person created by the Servlet : <jsp:getProperty name="name" property="Name" />
</body>
</html>

JSP页面
由Servlet创建的人员:
我无法找到异常的原因。

  • 属性应该是小写的
    私有字符串名
    ——这是由java约定和javabeans标准规定的
  • 标记应该再次使用小写的
    property=“name”
    -javabean
  • bean的名称不应该是
    name
    ,这很容易混淆。将其设置为
    nameBean
    (最好是小写)
  • 你们班应该有一个包。默认包会导致问题
  • 您可以简单地使用EL:
    ${nameBean.name}
    将解析为正确的值,而不是
    jsp:
    标记

尝试对类
Bean
中的成员和
Controller
中的属性名称使用
name
而不是
name
。是!问题解决了。(问题集还包括默认的包!),但是我得到了
null
,其中我期望由
bean.setName(“Suhail Gupta”)
设置的名称。这可能是什么原因?
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
    <jsp:useBean id="name" class="Bean" scope="request" />
    Person created by the Servlet : <jsp:getProperty name="name" property="Name" />
</body>
</html>