问题
In my application,with the help of joining,I am showing the dynamic value in my jsp page like this :
<% while(rs.next()){ %>
<td><input type="checkbox" name="chkName" onclick="selectall()"></td>
<td><input type="text" name="empId" value="<%= rs.getString(1)%> " disabled="disabled" maxlength="10"></td>
<td><input type="text" name="device" value="<%= rs.getString(2)%>" disabled="disabled" maxlength="10"></td>
<td><input type="text" name="features" value="<%= rs.getString(3)%>" disabled="disabled" maxlength="60"></td>
<td><input type="password" name="password" disabled="disabled"></td>
<td><input type="text" name="policyName" value="<%= rs.getString(4)%>" disabled="disabled" maxlength="10"></td>
</tr>
<% }
%>
And whenever from another servlet(as I want to show the fetching from this jsp to another jsp ) I am calling request.getParameter("empId"),it is fetching the "NULL" value.I think,I have to use set(session.setAttribute() or request.setParameter()).
Any suggestion will be appreciated.
回答1:
Might be because of the disabled attribute .. maybe you can replace it with readonly instead?
回答2:
Do you mean to say you need to pass values between 2 jsp pages? Then you could use it by setting it in a hidden input field or set it in session...
check if this helps you... Using request.setAttribute in a JSP page
回答3:
Another simple way.
You can add a hidden type .
<td><input type="text" value="<%= rs.getString(1)%> " disabled="disabled" maxlength="10"></td>
<td><input type="hidden" name="empId" value="<%= rs.getString(1)%> " maxlength="10"></td>
回答4:
try request.getParameter("empID") for the field named empId not <i>empId. Hope that helped , just rename the field in the form
来源:https://stackoverflow.com/questions/10613117/getting-null-value-from-request-getparameter