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
The value for the useBean class attribute ... is invalid
提问by user62835
I want to use a Java file SaveProp
which 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件事
- Make sure the class file is under WEBINF/classes/user
- Make sure there is a public default constructor without arguments
- You can also use type= instead of class= if the bean already exists in the scope
- 确保类文件在 WEBINF/classes/user 下
- 确保有一个没有参数的公共默认构造函数
- 如果 bean 已经存在于作用域中,您也可以使用 type= 而不是 class=
回答by Monish Gandhi
Make sure that the default no-arg constructor is there and is public.
确保默认的无参数构造函数存在并且是公共的。