使用JSP的Request.getParameter [英] Request.getParameter with JSP

查看:77
本文介绍了使用JSP的Request.getParameter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据请求参数自动填充下拉列表.我对JSP还是很陌生,所以请原谅我这个简单的问题.

I'm trying to auto-populate a drop down list based on a request parameter. I'm fairly new to JSP so forgive me for the simple question.

以下内容可以正常工作并正确显示警报:

The following works fine and displays the alert correctly:

 alert('<%=request.getParameter("lang") %>');

所以我知道我要做的事情很容易.但是,当我使用以下语句在select语句中添加相同的逻辑时:

So I know what I am trying to do is easy enough. But when I add this same logic in with my select statement using:

<option <c:if test="${request.getParameter(\"lang\")=='En'}"> selected="selected" </c:if>    value="<c:out value="${english}"/>">English</option>

我收到一个异常消息:未指定默认名称空间时,必须将函数getParameter与前缀一起使用".

I get an exception saying "The function getParameter must be used with a prefix when a default namespace is not specified".

我有点困惑为什么这在这里不起作用...

I'm a little confused as to why this doesn't work here...

预先感谢

推荐答案

request.getParameter()不会被EL解决.可以使用隐式变量param访问请求参数.即${param.lang}

request.getParameter() will not resolved by EL. Request parameter can be accessed using implicit variable param. i.e, ${param.lang}

更改此

<option <c:if test="${request.getParameter(\"lang\")=='En'}"> selected="selected" </c:if>    value="<c:out value="${english}"/>">English</option>

<option <c:if test="${param.lang == 'En'}"> selected="selected" </c:if> value="${english}">English</option>

这篇关于使用JSP的Request.getParameter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆