第一种:
jsp代码:
-
<
select
id
=
“csrqnf”
name
=
“csrqnf”
id
=
“selecte”
class
=
“shortselect”
value
=
“${nfResult}”
>
-
<
option
value
=
“”
>
—请选择年份–
</
option
>
-
<
c:forEach
items
=
“${listYears}”
var
=
“years”
varStatus
=
“vs”
>
-
<
option
value
=
“${years}”
>
${years}
</
option
>
-
</
c:forEach
>
-
</
select
>
-
<
script
type
=
“text/javascript”
>
-
document.getElementById(“csrqnf”)
.value
=
“${nfResult}”
;
-
document.getElementById(“csrqnf”)[${nfResult}]
.selected
=
true
;
-
-
</
script
>
后台java代码:
-
request.setAttribute(“nfResult”,”2013″);
网上摘抄:
-
<!–
-
实现select标签回显
-
–>
-
1.
<
select
name
=
“curStatus”
value
=
“${curStatus}”
>
-
<
option
value
=
“0”
>
-请选择-
</
option
>
-
<
option
value
=
“1”
<
c:if
test
=
“${‘1’ eq curStatus}”
>
selected
</
c:if
>
>
男
</
option
>
-
<
option
value
=
“2”
<
c:if
test
=
“${‘2’ eq curStatus}”
>
selected
</
c:if
>
>
女
</
option
>
-
</
select
>
-
-
2.
<
s:select
list
=
“#{0:’–请选择–‘,1:’处理中’,2:’已完成’}”
listKey
=
“key”
listValue
=
“value”
name
=
“curStatus”
value
=
“%{curStatus}”
>
</
s:select
>
-
-
3.
<
select
name
=
“curStatus”
value
=
“${curStatus}”
>
-
<
option
value
=
“0”
>
-请选择-
</
option
>
-
<
option
value
=
“1”
<
s:if
test
=
“%{curStatus==1}”
>
selected
</
s:if
>
>
处理中
</
option
>
-
<
option
value
=
“2”
<
s:if
test
=
“%{curStatus==2}”
>
selected
</
s:if
>
>
已处理
</
option
>
-
</
select
>