努力GOGO
2015-11-29 22:13
用户名:<jsp:getProperty property="username" name="myUsers"/><br>
密码:<jsp:getProperty property="password" name="myUsers"/><br>
提示错误信息
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: file:/dologin.jsp(40,4) jsp:getProperty for bean with name 'myUsers'. Name was not previously introduced as per JSP.5.3
<jsp:useBean id="实例化对象名" class="所定义的类"
用户名:<jsp:getProperty property="username" name="实例化对象名"/><br>
<jsp:setProperty property="password" name="myUsers" param="mypass"/>
后面的应该是value="mypass"
我把我写的代码发上来吧
package pack; public class MyBean { private String name; private String password; public String getName(){ return name; } public void setName(String name){ this.name=name; } public String getPassword(){ return password; } public void setPassword(String password){ this.password=password; } }
<%@ page language="java" contentType="text/html; charset=utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <jsp:useBean id="mybean" class="pack.MyBean" scope="page"/> <jsp:setProperty name="mybean" property="name" value="jack"/> <jsp:setProperty name="mybean" property="password" value="abc123"/> username: <jsp:getProperty property="name" name="mybean" /><br> password: <jsp:getProperty property="password" name="mybean"/><br> </body> </html>
<body>
<jsp:useBean id="myUsers"class="com.po.Users"scope="application"/>
<h1>setProperty动作元素</h1>
<hr><jsp:setProperty property="password" name="myUsers" param="mypass"/>
<jsp:setProperty property="username" name="myUsers" />
用户名:<jsp:getProperty property="username" name="myUsers"/><br>
密码:<jsp:getProperty property="password" name="myUsers"/><br>
</body>
对着呢阿 我不清楚哪错了
JAVA遇见HTML——JSP篇
248278 学习 · 3071 问题
相似问题