gpt4 book ai didi

java - 错误: The value for the useBean class attribute user. CompileClasss无效

转载 作者:行者123 更新时间:2023-11-30 05:04:57 26 4
gpt4 key购买 nike

我收到useBean 类属性 user.CompileClasss 的值无效这些是我的文件:

index.jsp

<%@ page session="true" %>
<%@ page import="user.CompileClass" %>

<jsp:useBean id="user1" class="user.CompileClasss" scope="session" />
<jsp:setProperty name="user1" property="*"/>
<html>
<body>
<FORM METHOD=POST ACTION="Result.jsp">
What's your name? <INPUT TYPE=TEXT NAME=uname SIZE=20><BR>
What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
<P><INPUT TYPE=SUBMIT>
</FORM>
</body>
</html>

CompileClass.java

package user;

public class CompileClass {
public String uname;
public String mail;
public int age;

/*public CompileClass(String uname, String mail, int age) {
this.uname=uname;
this.mail=mail;
this.age=age;
}*/
public CompileClass(){
}



public String returnname(){
return uname;
}
public String returnmail(){
return mail;
}
public int returnage(){
return age;
}


/*public void main()
{


}*/
}

Result.jsp

<jsp:useBean id="user1" scope="session" class="user.CompileClass" />
<html>

<body>
You entered:<BR>

Name: <%= user1.returnname() %> <BR/>
Email: <%= user1.returnmail() %><BR>
Age: <%= user1.returnage() %><BR>
</body>
</html>

有什么帮助吗?

最佳答案

您的 JavaBean 格式错误。阅读 this article以获得解释。

更新:错误的 JavaBean 格式破坏了这行代码:

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

应用程序服务器无法找到表单参数和 Bean 字段之间的映射。

还有一个问题,你应该放置

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

进入Result.jsp,因为没有定义属性,当Index.jsp运行时。

关于java - 错误: The value for the useBean class attribute user. CompileClasss无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5418512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com