我一下,像這樣的NullPointerException同時設定了豆
/SocialStupendous/GetProfile.action?slno=3&slno=3
一個超鏈接在我的ActionClass
execute
方法後,有一個動作URL我有以下代碼
public String execute() {
int urislno=Integer.parseInt(getServletRequest().getParameter("slno"));
System.out.println(urislno);
bean.setUslno(urislno);
}
我得到NullPointerException
時我正在執行bean.setuslno(urislno)
。即使urislno
正確打印爲3
。
ProfileBean
類:
public class ProfileBean {
private int uslno;
public int getUslno() {
return uslno;
}
public void setUslno(int uslno) {
this.uslno = uslno;
}
}
這究竟是爲什麼?
你爲什麼要直接從擺在首位請求訪問的參數?關於NPE,在看到什麼是空的後不應該很明顯是什麼錯? –
我想要抓住那些點擊了getprofile.action這個網址的用戶。通過他/她的slno來捕捉用戶的唯一方法。因此,我想測試我是否能夠訪問url中的參數,這些參數對應於用戶的更改 –
沒有必要直接訪問請求,請使用av action屬性。 –