jsp表单在一个输入中返回null值

时间:2014-08-23 12:05:28

标签: java forms jsp spring-mvc

JSP代码:

<form method="POST" action="editing.jsp">
    <div class="line">
        <span class="Stk">Current Password:</span><input type="password" name='pass' />
    </div>

    <div class="line">
        <span class="Stk">New<br>Password:</span><input type="password" name='neopass' />
    </div>

    <div class="line">
        <span class="Stk">Confirm Password:</span><input type="password" name='passcon' />
    </div>
    <br>

    <div class="line">
        <input type="submit" value="Change Password"/>
    </div>
 </form>

.java代码:

public class myUser {

    private String pass = null;
    private String neopass = null;
    private String passcon = null;

    public void myUser(){

    }

    public String getPass(){
        return this.pass;
    }

    public void setPass(final String pass){     
        this.pass = pass;
    }

    public String getPasscon(){
        return this.passcon;
    }

    public void setPasscon(final String passcon){
        this.passcon = passcon;
    }

    public String getneoPass(){
        return this.neopass;
    }

    public void setneoPass(final String neopass){
        this.neopass = neopass;
    }
}

我尝试制作表单,以便在我的应用中更改密码!问题是,即使我认为我已经做得很好,但是出了问题,它不起作用!当我打印我在表单中设置的值时(通过 Beans。&#39; nameofmethod&#39;(例如Bean.getneoPass() )我在passpasscon输入中输入的值正常显示,但neopass输入中的值似乎始终为 null

1 个答案:

答案 0 :(得分:2)

你的neopass方法应该是getNeopass()setNeopass()来匹配你的neopass表单项。 (不是setneoPass - 错误的上限)