0

我是高级 java 和学习 Spring 框架的新手。我找到了一个教程

http://netbeans.org/kb/docs/web/quickstart-webapps-spring.html

在下面的代码中

package contoller;

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;
/**
*
* @author Manish
*/
public class HelloController extends SimpleFormController {

public HelloController() {
setCommandClass(Name.class);
setCommandName("name");
setSuccessView("helloView");
setFormView("nameView");
}
 private HelloService helloService;
 public void setHelloService(HelloService helloService) {
 this.helloService = helloService;
  }

@Override          // Error Method does not override or implment a method of supertype
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;
  }

我该如何解决这个问题?

问候。

4

1 回答 1

1

错误:方法没有覆盖或实现超类型的方法

这与 Spring 无关。它说在你的SimpleFormController课堂上没有方法onSubmit

将此方法添加到您的SimpleFormController类中,问题就解决了。

于 2012-12-22T08:55:07.027 回答