首页 > 代码库 > 有效范围为request的bean

有效范围为request的bean

 

Car.java类

package tom.jiafei;

public class Car {
    String carnumber;
    String name;
    String date;

    public String getCarnumber() {

        try {
            byte b[] = carnumber.getBytes("iso-8859-1");
            carnumber = new String(b);
        } catch (Exception exp) {
        }
        return carnumber;
    }

    public void setCarnumber(String carnumber) {

        this.carnumber = carnumber;
    }

    public String getName() {
        try {
            byte b[] = name.getBytes("iso-8859-1");
            name = new String(b);
        } catch (Exception exp) {
        }

        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDate() {
        try {
            byte b[] = date.getBytes("gb2312");
            date = new String(b);
        } catch (Exception exp) {
        }
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

}

 

 

inputAndShow.jsp页面

<%@page contentType="text/html; charset=gb2312"%>
<jsp:useBean id="car" class="tom.jiafei.Car" scope="request"></jsp:useBean>

<form action="" method="post">
    <label>汽车的牌号 </label> <input type="text " name="carnumber"><br>
    <label>汽车的名称 </label> <input type="text " name="name"><br>
    <label>汽车的生产日期 </label> <input type="text " name="date"><br>
    <input type="submit" name="submit" value="http://www.mamicode.com/提交">
</form>
<jsp:setProperty property="*" name="car" /><br>

汽车的牌号<jsp:getProperty property="carnumber" name="car" /><br>
汽车的名称<jsp:getProperty property="name" name="car" /><br>
汽车的生产日期<jsp:getProperty property="date" name="car" /><br>

 

有效范围为request的bean