我正在尝试将信息从我的 servlet 传递到 jsp ,其中一些字段成功传递,而另一些则没有。
这是我输入输入的初始页面:
的代码index.html
<!DOCTYPE html>
<html>
<head><title>Bank application</title>
<link rel="stylesheet"
href="./css/styles.css"
type="text/css"/>
</head>
<body>
<table class="title">
<tr><th>Web Bank application</th></tr>
</table>
<br/>
<fieldset>
<legend>Registration</legend>
<form action="register">
First name: <input type="text" name="firstName"><br>
Last name : <input type="text" name="lastName"><br>
Address : <input type="text" name="address"><br>
ID-number : <input type="text" name="idnumber"><br>
User-Name : <input type="text" name="userName"><br>
Password : <input type="text" name="password"><br>
<input type="submit" value="Register">
</form>
</fieldset>
我想将数据传递给一个名为show-name.jsp
:
<!DOCTYPE html>
<html>
<head><title>Thanks for Registering</title>
<link rel="stylesheet"
href="./css/styles.css"
type="text/css"/>
</head>
<body>
<h1>Congratulations ! You are now registered to our bank</h1>
<h2>First Name: ${name.firstName}</h2> // that's okay
<h2>Last Name: ${name.lastName}</h2> // that's okay
<h2>Address: ${name.address}</h2> // that's okay
<h2>Password: ${name.password}</h2> // that's okay
<h2>User-Name: ${name.userName}</h2> // that's not okay
<h2>Id Number: ${name.idnumber}</h2> // that's not okay
</body></html>
我在 Eclipse 中得到以下异常:
root cause
javax.el.PropertyNotFoundException: Property 'userName' not found on type model.Person
或者 :
root cause
javax.el.PropertyNotFoundException: Property 'idnumber' not found on type model.Person
奇怪的是,所有其他4
字段都很好,意思是name.firstName
& name.lastName
& name.address
& name.password
,但其他两个不是,即使我添加了几个System.out.prinln
-s :
System.out.println(person.getID());
System.out.println(person.getUsername());
在servlet中,数据提交console
成功,意思是我得到:
4444
5555
. 但由于某种原因,数据部分没有传递给jsp
.
为什么 ?
谢谢