更新时间:2023-01-16 17:14:02
没有.不幸的是,Request 对象仅在页面完成加载之前可用 - 一旦完成,您将丢失其中的所有值,除非它们已存储在某处.
No. Unfortunately the Request object is only available until the page finishes loading - once it's complete, you'll lose all values in it unless they've been stored somewhere.
如果您想通过请求保留属性,您需要:
If you want to persist attributes through requests you need to either:
"/>
.这将在 servlet 中作为请求参数提供.request.getSession()
- 在 JSP 中,这仅作为 session
可用)<input type="hidden" name="myhiddenvalue" value="<%= request.getParameter("value") %>" />
. This will then be available in the servlet as a request parameter.request.getSession()
- in a JSP this is available as simply session
)我建议使用会话,因为它更易于管理.
I recommend using the Session as it's easier to manage.