I have a servlet controller for a jsp file. I pass some parameters to this file when loading it, via request.setAttribute()
, from the servlet. However, I need to include another nested jsp from the main jsp file. Will the nested file have access to the params which were sent? If not, how can I pass those params to the nested file?
是的,嵌套的jsp将看到从servlet控制器设置的请求范围属性。
use jstl's set method in the parent jsp and use the same variable in jspf.
In parent jsp.
<c:set var="foo" value="bar"/>
In included jspf.
<h2>The included parameter is ${foo}</h2>
Also you can access all the attributes set inside a servlet using request.setAttribute()
in the jsp page using EL eg ${attributeName}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.