I have a jsp form:
<f:form modelAttribute="myform" action="" id="forma">
<f:select path="nameOfTable" onchange="MyMethod()" name="tableName" id="tableName" >
<f:options items="${valmap}"/>
</f:select>
<input type="submit" value="Submit" onclick="constructUrl(forma)"/>
</f:form>
The valmap is a map with string key and value. I come to this jsp page from another page with a similar form, so this is more like navigation menu. How can I make the select show me a specific value by default, not the first in the map? I can pass the key and write selected="valmap.get.key" but it suddenly always makes the last one value selected, not the one I need
just use this between your f:select and f:options! If you want "show" the default just do it
<form:option selected="true" value="show" />
<f:select path="nameOfTable" onchange="MyMethod()" name="tableName" id="tableName" >
<f:option selected="true" value="theValueYouNeed" />
<f:options items="${valmap}"/>