Reputation: 21
I am writing a jsp page for adding some data to a SQL database, and one of the items is a dropdown list of specific enums in the db.
However, even with them selected, only the text manually entered is being sent to the db, and nothing from the dropdown lists is populating the Spring MVC model.
Am I forgetting to add anything on this jsp page? I truncated a bunch to save space.
<div class="form-group">
<label>Utility Type</label>
<div style="margin: 0 0 0 0">
<select name="year" style="width:130px">
<option value="IOU">Investor Owned</option>
<option value="Coop">Cooperative</option>
<option value="Muni">Municipality</option>
</select>
</div>
<div><form:errors path="type" cssClass="errors" /></div>
</div>
<div class="form-group">
<label>Commodity Type</label>
<div style="margin: 0 0 0 0">
<select name="year" style="width:130px">
<option value="Elec">Electric</option>
<option value="Gas">Gas</option>
<option value="E&G">Electric & Gas</option>
</select>
</div>
<div><form:errors path="commodityType" cssClass="errors" /></div>
</div>
Upvotes: 0
Views: 291
Reputation: 21
For anyone that comes across this issue, I have figured it out. I did not mark the JSTL select tags as a form with a path to where in the database it should be saved. Here is the correct version of the code where you can see the changes.
<form:select path="type" style="width:130px">
<option value="IOU">Investor Owned</option>
<option value="Coop">Cooperative</option>
<option value="Muni">Municipality</option>
</form:select>
The same goes for the second block of code that I had above.
Upvotes: 0