无法在JSP中使用类别

无法在JSP中使用类别

本文介绍了无法在JSP中使用类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我在Java Web Project的包中定义的类,但是当我使用在包中定义的类时,会不断出错.该错误表明该类无法解析为类型.我正在导入制作的包含我要使用的类的包.

I'm trying to use a class I defined in a package in my Java Web Project, however I keep getting errors when I use the class I defined in the package. The error is saying that the class cannot be resolved to a type. I am importing the package that I made that contains the class that I want to use.

推荐答案

该类需要位于Webapp的/WEB-INF/classes中的文件夹结构中,该文件夹结构表示已声明的package.因此,如果您有例如

The class needs to be located in webapp's /WEB-INF/classes in a folder structure which represents the declared package. So if you have for example

package com.example;

public class Foo {
    // ...
}

然后您应该有一个/WEB-INF/classes/com/example/Foo.class文件.请记住,这与Java中的其他所有内容一样区分大小写.

then you should have a /WEB-INF/classes/com/example/Foo.class file. Please keep in mind that this is case sensitive as everything else in Java.

另一个可能的原因是,当您尝试在<jsp:useBean>标记中使用它时,它应该具有一个(隐式)默认构造函数,该构造函数在构造时不会引发异常.

Another possible cause is when you're trying to use it in a <jsp:useBean> tag, that it should have a (implicit) default constructor which doesn't throw an exception upon construction.

这篇关于无法在JSP中使用类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:20