用到spring mvc + hibernate 开发,遇到一个删除操作时,让他重定向到一个显示列表的页面,出现错误。
java.lang.IllegalArgumentException: attempt to create delete event with null entity
在controller 里面  写的
@RequestMapping("delete/{id}")
public String delete(User user,@PathVariable String id){
User user1 = this.baseDao.get(User.class, id);
System.out.println(id);
this.baseDao.delete(user1);
return "redirect:success"; }
是不是上面红色重定向出了问题,解决方法附上,谢谢

解决方案 »

  1.   

    嗯。 确实写错了。 以跳转到CSDN首页为例。return "redirect:http://www.csdn.net";redirect:以后也可以跟相对地址但不是逻辑视图名称如return "redirect:xxx.do?param1=value1";  // 带参数的请求
      

  2.   

    @Controller
    public class ContactController {
        @RequestMapping(value = "/addContact", method = RequestMethod.POST)
        public String addContact(@ModelAttribute("contact") Contact contact, BindingResult result) {
            // @ModelAttribute will binds the data from request to the object
            // Contact.
            System.out.printf("Name: %s, Mail: %s\n", contact.getName(), contact.getMail());
            return "redirect:contacts.htm"; // 看这里
        }    @RequestMapping("/contacts")
        public ModelAndView showContacts() {
            return new ModelAndView("contact", "command", new Contact());
        }
    }
      

  3.   

    可以直接写一个successs就可以了 spring mvc 可以帮您找到路径的