Spring form submit validation for foreign key -


itemprop = "text">

My project is a Spring MVC project. In my project I have a domain technology that has foreign key reference. When I submit the form it throws the error .... For the part of the view (JSP), I am using the form: Viewing in the field of technology Select for How can I validate a foreign reference ????? I tried the code below

Domain

  @ Entity @Table (name = "technology") Public category technology {Private IIT; @n private letter's name; @Department of Private Department; Personal date created date; Private Boolean is Dell; }   

message.properties NotEmpty.technology.department = Required!

technology.jsp

  & lt; Form: form method = "post" action = "add-technology" commandName = "technology" id = "technology format" & gt; & Lt; Label & gt; Technology name & lt; / Label & gt; & Lt; Form: Input path = "name" /> & Lt; Form: Errors path = "name" class = "error" & gt; & Lt; / Form: errors> & Lt; Br / & gt; & Lt; Label & gt; Department & lt; / Labels & gt; & Lt; Form: Select Path = "department.id" & gt; & Lt; Form: Option value = "0" label = "Select" /> & Lt; Appearance: Option item = "$ {department}" item value = "id" item label = "name" /> & Lt; / Form: select & gt; & Lt; Form: Errors Path = "Dept." Class = "Error" & gt; & Lt; / Form: errors> & Lt;% - & lt; Form: Select path = "department.id" item = "$ {div}}" & gt; -% & gt; & Lt; Input type = "submit" class = "btn btn-primary" /> & Lt; / Form: Form & gt; Public string addTechnology (@ModeelAttribute (value =)   

Controller

  @RequestMapping (value = "/ add-technology" "Technology") @ legitimate technology technology, binding result results) {if (result.hasErrors ()) {return "/ secure / admin / technology"; } Java.util.Date utility = new java.util.Date (); Date sqlDate = new date (use date .getTime ()); Technology.setCreatedDate (sqlDate); TechnologyService.saveTechnology (technology); Return "Redirect: / Techniques"; }   

Error

  org.springframework.web.util.NestedServletException: The request process failed; Nested exception javax.validation.UnexpectedTypeException: No validator found for type: com.company.product.domain.Department   

How can I solve this problem ???

Here you have to implement the validator for technical objects

  class TechnologyValidator enhances the recognizer {public boolean support (class   

and bean

  @ etavaire technolygalydic tech wild; in this spring-context;   

and call this controller like your controller

  @RequestMapping (value = "/ add-technology") public string addTechnology (@ModelAttribute (value = "Technology") Technology Technology, Binding Results Result) {// Call Vedicator techValid.validate (technique, results); If (result.hasErrors ()) {return "/ secure / admin / technology"; } Java.util.Date utility = new java.util.Date (); Date sqlDate = new date (use date .getTime ()); Technology.setCreatedDate (sqlDate); TechnologyService.saveTechnology (technology); Return "Redirect: / Techniques"; }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -