请问下我哪错了???

来源:5-7 getProperty

努力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


写回答 关注

4回答

  • Rober_Lin
    2015-11-29 22:28:14
    已采纳

    <jsp:useBean id="实例化对象名" class="所定义的类"

    用户名:<jsp:getProperty property="username" name="实例化对象名"/><br>

    努力GOGO

    我不知道哪错了 语法对着呢 值也对着呢

    2015-11-29 22:38:09

    共 1 条回复 >

  • Rober_Lin
    2015-11-30 12:06:18

    <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>



  • 努力GOGO
    2015-11-29 22:45:09

    <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>


  • 努力GOGO
    2015-11-29 22:37:32

    对着呢阿 我不清楚哪错了

JAVA遇见HTML——JSP篇

Java Web入门级教程JSP,带你轻松的学习JSP基础知识

248278 学习 · 3071 问题

查看课程

相似问题