当我点击提交按钮时,我收到此错误消息
Whitelabel错误页面此应用程序没有明确的映射 /错误,所以你看到这是一个后备。 Tue Jun 30 17:24:02 CST 2015出现意外错误(type = Not Found,status = 404)。没有 消息可用
这是我的代码。
package com.tourpackage.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.bind.annotation.RestController;
import com.tourpackage.model.TourPackage;
import com.tourpackage.repository.TourPackageMongoRepository;
import com.tourpackage.repository.VehicleTypeMongoRepository;
@Controller
public class TourPackageController {
@Autowired
TourPackageMongoRepository packageRepository;
VehicleTypeMongoRepository vehicleTypeRepository;
@RequestMapping("/tourpackage")
public String tourpackage(Model model){
model.addAttribute("packagelist", packageRepository.findAll());
return "index";
}
@RequestMapping("/addNewTour")
public String addNewTour(Model model){
model.addAttribute("packagelist", packageRepository.findAll());
return "tourpack";
}
@RequestMapping(value="/addPackage", method = RequestMethod.POST)
public String addPackage(@ModelAttribute TourPackage tourpack) {
packageRepository.save(tourpack);
return "redirect:tourpackage";
}
}
答案 0 :(得分:0)
@RestController public class MyController实现了ErrorController {
private static final String PATH = "/error";
@RequestMapping(value = PATH)
public String error() {
return "Error handling";
}
@Override
public String getErrorPath() {
return PATH;
}
}
否则, 如果你想禁用它,你可以参考这篇文章: http://www.logicbig.com/tutorials/spring-framework/spring-boot/disable-default-error-page/