0

Trying out this tutorial from here.

Created a dynamic web project and the code as it is. However when I deploy and run this on Tomcat, getting this exception:

org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)

I tried to google it and also tried modifying the controller class:

package com.tutorialspoint;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.portlet.ModelAndView;

@Controller
public class StudentController {
    @RequestMapping(value="/student", method=RequestMethod.GET)
    public ModelAndView student(){
        ModelAndView mAndV =  new ModelAndView("student");
        mAndV.addObject("command",new Student());
        return mAndV;
        /*return new ModelAndView("student","command",new Student());*/
    }

    @RequestMapping(value="/addstudent", method=RequestMethod.POST)
    public String addStudent(@ModelAttribute("SpringWeb")Student student, ModelMap model) {

        model.addAttribute("name",student.getName());
        model.addAttribute("age",student.getAge());
        model.addAttribute("id",student.getId());

        return "result";
    }
}

But its not helping... I know this must be an simple issue. But not getting what it is.

Jose Rodriguez
  • 9,753
  • 13
  • 36
  • 52
AbhijitG
  • 59
  • 1
  • 1
  • 8

0 Answers0