简体   繁体   English

为什么jsp request.getParameter(“ String”)在第一次调用后返回null?

[英]Why does jsp request.getParameter(“String”) return null after the first call?

If I run my web project, in the first call I get the right Parameter (request.getParamter(userid)), but if I do more then one call, the request.getParamter Method always returns null. 如果运行我的Web项目,则在第一个调用中,我将获得正确的参数(request.getParamter(userid)),但如果执行多个调用后,则request.getParamter方法始终返回null。

I don't know why, and I have tried many things. 我不知道为什么,我尝试了很多事情。

Thank you for your help. 谢谢您的帮助。

in jsp I have this: 在jsp中,我有这个:

function addPersonToDatabase(userID){

var check = 0;
for (var zaehler = 0; zaehler < (document.getElementsByName("notinProject[]").length);   
 zaehler++) {

if (document.getElementsByName("notinProject[]")[zaehler].checked) {

location.href='<%=request.getContextPath()%>/administration/persons
action=addfrompersons&comingfrom=' + location.href + '&username=' + userID; 
        check++;
         }      
}


<form name='setcheckbox' id='setcheckbox' action='PersonControllerServlet' method='post' >

<input type="checkbox" name="notinProject[]" value="" onclick='javascript:addPersonToDatabase("
<%=lobjPerson.userName%)'><br> </td>

in servlet I have this: 在servlet中,我有这个:

String lstrUserName=request.getParameter("username");

尝试:

onclick='javascript:addPersonToDatabase("<%=lobjPerson.userName%>")'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM