Boa tarde e Feliz Natal a todos!
Estou com o seguinte problema tenho um cadastro de usuários que é uma pagina JSP, quando tento gravar um usuario no banco ocorre o seguinte erro:
Grave: Servlet.service() for servlet [Spring_MVC_Dispatcher_Servlet] in context with path [/SGE] threw exception [Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'usuario' on field 'perfil': rejected value [br.com.sge.modelo.Perfil@19de339]; codes [typeMismatch.usuario.perfil,typeMismatch.perfil,typeMismatch.br.com.sge.modelo.Perfil,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [usuario.perfil,perfil]; arguments []; default message [perfil]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'br.com.sge.modelo.Perfil' for property 'perfil'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [br.com.sge.modelo.Perfil] for property 'perfil': no matching editors or conversion strategy found]] with root cause
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'usuario' on field 'perfil': rejected value [br.com.sge.modelo.Perfil@19de339]; codes [typeMismatch.usuario.perfil,typeMismatch.perfil,typeMismatch.br.com.sge.modelo.Perfil,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [usuario.perfil,perfil]; arguments []; default message [perfil]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'br.com.sge.modelo.Perfil' for property 'perfil'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [br.com.sge.modelo.Perfil] for property 'perfil': no matching editors or conversion strategy found]
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:110)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:647)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:603)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:859)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:883)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:792)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Meu objeto Usuário tem um atributo Perfil e preciso passa-lo para a criação de um Usuário valido segue abaixo o meu form
<form action="cadastrarUsuario" method="post">
<div class="label"><label for="nome_usuario">Nome:</label></div><input class="input_texto" type="text" name="nome_usuario" id="nome_usuario"/><br/>
<div class="label"><label for="email_usuario">Email:</label></div><input class="input_texto" type="text" name="email_usuario" id="email_usuario"/><br/>
<div class="label"><label for="login_usuario">Login:</label></div><input class="input_texto" type="text" name="login_usuario" id="login_usuario"/><br/>
<div class="label"><label for="senha_usuario">Senha:</label></div><input class="input_texto" type="password" name="senha_usuario" id="senha_usuario"/><br/>
<div class="label"><label for="perfil">Perfil:</label></div>
<select id="perfil" name="perfil">
<option value="">Selecione...</option>
<c:forEach items="${lista_perfil}" var="perfil">
<option value="${perfil}">${perfil.tipo_perfil}</option>
</c:forEach>
</select>
<div class="botoes"><input type="submit" value="Cadastrar" /><input type="reset" value="Limpar" /></div>
</form>
alguém pode me ajudar ?