Хай, извините за мой английский не очень хорошо, я работаю с весны MVC от 1 недели и
Я бы загрузил список объектов, чтобы выбрать форму и захватить результат выбора списка.
Класс контроллера это:
@Controller
public class LoginLRI_Controller {
@RequestMapping(value = "/")
public String login(Model model) {
Utente utente = new Utente();
model.addAttribute("utenteLogin", utente);
return "Lri";
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ModelAndView loginController(@Valid @ModelAttribute("utenteLogin") Utente utente, BindingResult errors,
Model model) {
if (errors.hasErrors()) {
return new ModelAndView("Lri");
} else {
Collection<Organizzazioni> listOrganizzation = new ArrayList<Organizzazioni>();
ConnectToDatabase c = new ConnectToDatabase();
Query query = new Query();
Boolean loginResp = query.login(utente.getUsername(), utente.getPassword());
if (loginResp) {
System.out.println("login riuscito : " + loginResp);
listOrganizzation = query.loadOrganizzation(utente.getUsername());
model.addAttribute("listOrganizzation", listOrganizzation);
Organizzazioni organizzationCom = new Organizzazioni();
model.addAttribute("organizzationCom", organizzationCom);
return new ModelAndView("Organizzation");
} else {
System.out.println("login non riuscito : " + loginResp);
return new ModelAndView("Lri");
}
}
}
Класс Organizzazioni это:
public class Organizzazioni {
private int id_organizzazione;
private String nome_organizzazione;
public int getId_organizzazione() {
return id_organizzazione;
}
@Override
public String toString() {
return nome_organizzazione;
}
public void setId_organizzazione(int id_organizzazione) {
this.id_organizzazione = id_organizzazione;
}
public String getNome_organizzazione() {
return nome_organizzazione;
}
public void setNome_organizzazione(String nome_organizzazione) {
this.nome_organizzazione = nome_organizzazione;
}
и это моя страница Organizization.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Inserire Organizzazione</title>
</head>
<body>
<form:form commandName="organizzationCom" action="" method="POST">
<form:select path="listOrganizzation" >
<form:option value="-" label="--SELECT--"></form:option>
<form:options items="${listOrganizzation}" itemValue="Organizzazioni"/>
</form:select>
<input type="submit" value="Salva">
</form:form>
</body>
</html>
при компиляции я не могу решить эту проблему: ошибка:
HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/views/Organizzation.jsp at line 16
The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/Organizzation.jsp at line 16
13: </head>
14: <body>
15: <form:form commandName="organizzationCom" action="" method="POST">
16: <form:select path="listOrganizzation" >
17: <form:option value="-" label="--SELECT--"></form:option>
18: <form:options items="${listOrganizzation}"/>
19: </form:select>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
пожалуйста, кто-нибудь может мне помочь? я остановился с 4 часов, я не очень хорошо к весне, но мне нужно работать, и я заблокирован