Java useBean 类属性的值...无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/545177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 16:03:13  来源:igfitidea点击:

The value for the useBean class attribute ... is invalid

javajsptomcatproperties

提问by user62835

I want to use a Java file SavePropwhich is written in a package user. The class file has been placed in WEBINF/classes. Below are the two lines which cause the issue.

我想使用一个SaveProp写在包中的 Java 文件user。类文件已放置在WEBINF/classes. 下面是导致问题的两行。

jsp:useBean id="user" class="user.SaveProp" scope="session"

jsp:setProperty name="user" property="*"

It throws:

它抛出:

The value for the useBean class attribute user.SaveProp is invalid

I'm using Tomcat 6.0.

我正在使用 Tomcat 6.0。

采纳答案by kgiannakakis

You should put the file under WEBINF/classes/user

您应该将文件放在 WEBINF/classes/user 下

回答by tiktock

3 things

3件事

  1. Make sure the class file is under WEBINF/classes/user
  2. Make sure there is a public default constructor without arguments
  3. You can also use type= instead of class= if the bean already exists in the scope
  1. 确保类文件在 WEBINF/classes/user 下
  2. 确保有一个没有参数的公共默认构造函数
  3. 如果 bean 已经存在于作用域中,您也可以使用 type= 而不是 class=

回答by Monish Gandhi

Make sure that the default no-arg constructor is there and is public.

确保默认的无参数构造函数存在并且是公共的。