为什么我不能在JSP文件中编译该类?错误500

时间:2018-06-09 05:33:17

标签: jsp servlets

我刚刚开始研究JSP,如果只有一个JSP文件就可以了。

我创建了一个用于测试JavaBeans的类文件,并始终收到错误“无法编译JSP类”和Web状态500.

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: [9] in the jsp file: [/index.jsp]
person cannot be resolved to a type


---------------------------- The 'person'.class code ------------

import java.lang.*;

public class person {

    private String name;
    private int age;
    private String sex;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

------------------------- The JSP file -------------------------

<%@ page language="java" contentType="text/html; charset=utf-8" %>
<html>
<head>
    <title>Java Bean Actions</title>
</head>

<body><br/>

    <jsp:useBean id="person" class="person" scope="page"></jsp:useBean>

    <jsp:setProperty name="person" property="*" />

1. Unable to compile the class "person"

2. person.class

3. The JSP file

1 个答案:

答案 0 :(得分:1)

原因是您的SELECT * from xyz WHERE time IN (SELECT time from xyz WHERE unit = 'some-unit') 班级位于person个文件夹。您的bean src必须具有包声明。

可以在 Unable to compile this class for JSP 找到更多详细信息。

顺便说一下,把你的课命名为person是一个坏主意,它应该以大写字母开头,如person