在Servlet中获取选定的下拉值 [英] Get selected dropdown value in servlet

查看:124
本文介绍了在Servlet中获取选定的下拉值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html中具有以下下拉值,并且正在使用 GET 方法将数据发送到servlet:

I have the below dropdown value in html and I am sending data to servlet using a GET method:

<select name="country">
    <option value="IN">India</option>
    <option value="AU">Australia</option>
    <option value="US">United States</option>
</select>

在servlet中,当我这样做时 request.getParameter("country"); 我正在进入美国,澳大利亚和美国而不是真实的国家名称

In servlet, when I do request.getParameter("country"); I am getting IN, AU and US instead of real country name

推荐答案

使用

<select name="country">
<option>India</option>
<option>Australia</option>
<option>United States</option>
</select>

相反.

或使用直接的BCP47代码( https://tools.ietf.org/html/bcp47 )

Or use the direct BCP47-Code (https://tools.ietf.org/html/bcp47)

 Locale.forLanguageTag(request.getParameter("country"))
    .getDisplayCountry(Locale.forLanguageTag("en_US"));

第4页表示,对于区域设置,最少2个ALPHA字符:

Page 4 sais 2 ALPHA-Characters are minimum for locale:

语言= 2 * 3ALPHA;最短的ISO 639代码

language = 2*3ALPHA ; shortest ISO 639 code

这篇关于在Servlet中获取选定的下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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