【问题标题】:Unable to compile class for jsp in tomcat 6.0.2.0无法在 tomcat 6.0.2.0 中为 jsp 编译类
【发布时间】:2012-02-15 10:07:32
【问题描述】:

在我看来一切都很好,但我仍然收到异常 "org.apache.jasper.JasperException: Unable to compile class for JSP:"

请查收

  • RootDirectory:- CallActionJsp
  • RootDirectory/action.jsp
  • 根目录/index.html
  • 根目录/meta-inf
  • RootDirectory/web-inf/classes/foo/Person.class
  • 根目录/web-inf/web.xml

================================================ ==========================

Index.html

<html>
<head>
<title>Index Page</title>
</head>
<body>

<form action="action.jsp" method="get">
<p align="left">Password: <input type="text" name="Password" /></p>
<BR>
<br>
<center><input type="SUBMIT" name="SUBMIT" /></center>
</form>
</body>
</html

Person.java

package foo;
public class Person
{
String name ;
    public void setName(String name)
    {
        this.name = name;
    }
    public String getName()
    {
        return name;
    }
}

action.jsp

<%@ page import="foo.*,java.util.Date"%>
<html>
<head>
<title>Action JSP</title>
</head>
<body>
<h1 align="center">Standard Actions are used Here.</h1>
<br>
<%
    Person p = new Person();
    Date date = new Date();
    out.print(date);
    String param = request.getParameter("Password");
    out.print("<br>"+param);
%>

<a href="CallActionJsp">Call Again </a>

</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">

    <servlet>
        <servlet-name>ActionJsp</servlet-name>
        <jsp-file>/action.jsp</jsp-file>
    </servlet>

    <servlet-mapping>
        <servlet-name>ActionJsp</servlet-name>
        <url-pattern>/CallActionJsp</url-pattern>
    </servlet-mapping>

</web-app>

问候 安库尔

【问题讨论】:

    标签: jsp jsp-tags


    【解决方案1】:

    快速猜测 - 由于RootDircetory/web-inf/classes/foo/Person.class 中的小写web-inf 找不到Person

    WEB-INF 必须是大写的名字,你可以尝试重命名吗?

    【讨论】:

    • 是的,非常感谢!!!它现在工作正常,我不知道这个大写问题,再次感谢你问候,Ankur
    • @AnkurGarg 您尚未接受任何问题的答案 - 请考虑这样做以获得更好的答案
    猜你喜欢
    • 1970-01-01
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 2016-12-22
    • 2017-05-12
    • 2017-12-13
    • 2013-11-10
    相关资源
    最近更新 更多