How to dynamically disable html <select> in

2019-09-09 11:40发布

I try to use

<select id="_${sec_field}_id" name="${sec_field}" multiple="${multiple}" "${(empty disabled) ? 'disabled' : ' '}" >

To get the <select> options dynamically enabled/disabled

But Eclipse give me the alerts:

Multiple annotations found at this line:
- Element type "select" must be followed by either attribute specifications, ">" or "/>".
- Attribute """ has no value

So is there any solution that we can work out the disable of html <select> in JSTL?

Thanks in advance.

1条回答
Summer. ? 凉城
2楼-- · 2019-09-09 12:21

Remove those doublequotes around the EL expression which prints the disabled attribute name. Doublequotes should be placed around the attribute value only (the part after =).

<select ... ${empty disabled ? 'disabled' : ''}>

otherwise you end up with

<select ... "">

or

<select ... "disabled">

which are syntactically wrong.

查看更多
登录 后发表回答