jsp中的java参数:include
我想知道是否可以将 java 变量传递给 .我尝试在 jsp 文件中执行类似的操作:
<% String folder = request.getParameter("something"); %>
<jsp:include page="../<%=folder%>/myframe.jsp" ></jsp:include>
这不起作用。我收到一条错误消息“无法找到资源/=folder/myframe.jsp”。 这可以做到吗?
感谢您的任何帮助。
I wanted to know if I can pass a java variable to a . I tried to do something like this inside a jsp file:
<% String folder = request.getParameter("something"); %>
<jsp:include page="../<%=folder%>/myframe.jsp" ></jsp:include>
This does not work. I get an error which says 'Failed to find resource /=folder/myframe.jsp'.
Can this be done?
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将页面参数作为整个字符串或整个替换。
此外,当在值内连接字符串时,您需要转义双引号。
所以对于你的问题:
应该工作正常,或者为了更容易阅读:
You either need to have the page parameter as an entire string or as an entire substitution.
Also when concatenating strings inside a value you need to escape the double quotes.
So for your problem :
Should work fine, or for easier reading :
将您的参数名称视为“某物”,
试试这个:
其他解决方案是这样做:
第一个更好,但两者都应该有效。
Concidering your param name as "something",
Try this:
Other solution is to do that:
First is better but both should works.