olá pessoal.
To seguindo um tutorial do site do netbeans para começar a usar o Spring na seguinte URL: LINK PARA TUTORIAL
O valor do form é passado mas a sucessView não mostra
desde já obrigado.
service.HelloService
package service;
public class HelloService {
public static String sayHello(String name) {
return "Hello " + name + "!";
}
}
controller.HelloController
package controller;
import java.net.BindException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import service.HelloService;
public class HelloController extends SimpleFormController {
private HelloService helloService;
public void setHelloService(HelloService helloService) {
this.helloService = helloService;
}
public HelloController() {
setCommandClass(Name.class);
setCommandName("name");
setSuccessView("helloView");
setFormView("nameView");
}
protected ModelAndView onSubmit(
HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors) throws Exception {
Name name = (Name) command;
ModelAndView mv = new ModelAndView(getSuccessView());
mv.addObject("helloMessage", helloService.sayHello(name.getValue()));
return mv;
}
}
package controller;
public class Name {
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
helloView.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<h1>Olá ${helloMessage} </h1>
</body>
</html>