I build a web application using jsp. I send parameters from servlet to jsp in get method to display them in jsp page when I request it. the problem is : when I submit the form to servlet and开发者_运维问答 then return to jsp I have to send these parameter with the request. How can I make a stable parameters so, I have to send them once (in get method only) and maintain them in jsp.
You could access request parameters by ${param}.
<input name="foo" value="${param.foo}">
...
<input type="radio" name="bar" value="a" ${param.bar == 'a' ? 'checked' : ''}>
...
<select name="baz">
<option value="b" ${param.baz == 'b' ? 'selected' : ''}>label</option>
...
<textarea name="boo">${param.boo}</textarea>
This basically prints request.getParameter("foo") as input value. This way the submitted value will be retained in the input elements.
same question here How can I retain HTML form field values in JSP after submitting form to Servlet?
精彩评论