문제

I have the following data

   <select  class="small" name="test"><option  value="1">a</option>

i want to print 'a' how can i do it? request.getparameter(test) gives me the selected value like 1

도움이 되었습니까?

해결책

You can't, at least not this way.

The general flow is this

  1. You have some model, containing both values (let's call them "value" and "display value")
  2. You output the <select> in a jsp and iterate over that model
  3. When the form is submitted back to the servlet/jsp, you get the "value" and, based on your model, get the corresponding "display value"

As pointed out in the comment below, the most widely used model is a Map implementation. TreeMap. HashMap, LinkedHashMap, depending on your data.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top