Spring mcv framework 3.0.2 RELEASE - Validation de formulaire
bjr les amis,
je vous donne ici un apercu de mon petit projet:
view,bref le formulaire:formulaire.jsp
Code:
1 2 3 4 5 6 7 8 9
|
<spring:nestedPath path="name">
<form action="" method="post">
<table><tr height="60"><td>
<spring:bind path="value">
Name:</td><td>
<input type="text" name="${status.expression}" value="${status.value}"></td></tr><tr><td>
</spring:bind>
......... |
controller:control.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public class HelloController extends SimpleFormController {
private HelloService helloService;
public void setHelloService(HelloService helloService) {
this.helloService = helloService;
}
public HelloController() {
//Initialize controller properties here or
//in the Web Application Context
setCommandClass(Name.class);
setCommandName("name");
setSuccessView("helloView");
setFormView("nameView");
}
//Use onSubmit instead of doSubmitAction
//when you need access to the Request, Response, or BindException objects
@Override
protected ModelAndView onSubmit(Object command) throws Exception {
Name name = (Name) command;
ModelAndView mv = new ModelAndView(getSuccessView());
mv.addObject("helloMessage", helloService.sayHello(name.getValue(),name.getValue1()));........... |
view2 qui affuche les donnees recues du formulaire:succes.jsp
Code:
1 2 3 4 5 6 7 8 9
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<h2>${helloMessage}</h2>
<a href="hello.htm">${isa}</a>..... |
l'objet concerné:name.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public class Name {
private String value;//name
private String value1;//adress
private String value2;//age
private int nombre;//
//nombre
public int getNombre() {
return nombre;
}
public void setNombre(int nombre) {
this.nombre = nombre;....... |
mes problemes:
-comment dois-je faire pour que mes inputs/string gere les accents? car la,c est pas le cas, &j uilise utf8 comme encodage de mes pages jsp
-comment interdire les champs vide dans mon formulaire
-comment faire pour retourner la vue sur le meme fichier formulaire.jsp
-bref des conseils ou codes pour la gestion des controles du formulaire
merci bcp pour votre aide.