Click here to Skip to main content
14,924,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am develoong spring web mvc application.

when i execute the page:
the following exception occurs:
javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items

here's the code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    <%@ taglib prefix="form" uri="" %>
<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<form:form action="processLogin" modelAttribute="user">
<form:select path="userType">
<form:options items="${user.userTypes}"/>
<form:input path="userId"/>
<form:input path="password"/>
<input type="submit" value="submit"/>


Home controller:
package com.rec.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rec.model.UserDetails;

public class HomeController {

	private static Logger log  = Logger.getLogger(HomeController.class);
	public String Home(Model model)
	{"Home Controller");
     UserDetails user= new UserDetails();
     model.addAttribute("user", user);
		return "Home" ;
	private String processForm(@ModelAttribute("user")UserDetails theUser)
		return "Discom-user-page.jsp";

What I have tried:

<form:select path="userType">
<form:option items="${user.userTypes}"/>
Sandeep Mewara 24-Sep-20 5:56am
Where is the code for: user.userTypes => is that a collection?
Richard MacCutchan 24-Sep-20 6:01am
The code states that items is a selection of options, but your code is passing a simple string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900