I want to validate the request parameter which is just a string value. Most of the examples on the net talks about validating a domain object with custom validator. But I want to write a validator just for String value. How to achieve that?
@Controller
@RequestMapping("/base")
class MyController{
//value needs to be validated.
@RequestMapping("/sub")
public String someMethod(@RequestParam String value, BindingResult result){
if(result.hasErrors()){
return "error";
}
//do operation
return "view";
}
}
Aucun commentaire:
Enregistrer un commentaire