我是高级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;
}
如何解决此问题?
问候。
答案 0 :(得分:1)
错误:方法不会覆盖或实现超类型方法
这与Spring无关。它在您的SimpleFormController
课程中说没有方法onSubmit
。
将此方法添加到SimpleFormController
课程中,问题就解决了。