Resolve "Сделать веб-приложение" #30

Merged
romanov73 merged 1 commits from 1-mvc into master 2021-03-17 09:15:24 +04:00
2 changed files with 0 additions and 27 deletions

View File

@ -1,18 +1,12 @@
package ru.ulstu.extractor.mvc;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
import ru.ulstu.extractor.mvc.model.EmailForm;
import javax.servlet.http.HttpServletRequest;
@Controller
public class GitExtractorController {
@GetMapping("/")
@ -29,15 +23,4 @@ public class GitExtractorController {
}
return "result";
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ModelAndView handleResourceNotFoundException(HttpServletRequest req, Exception ex) {
ModelAndView mav = new ModelAndView();
mav.addObject("exception", ex);
mav.addObject("url", req.getRequestURL());
mav.setViewName("error");
return mav;
}
}

View File

@ -15,16 +15,6 @@ class GlobalDefaultExceptionHandler {
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) {
// If the exception is annotated with @ResponseStatus rethrow it and let
// the framework handle it - like the OrderNotFoundException example
// at the start of this post.
// AnnotationUtils is a Spring Framework utility class.
/*if (AnnotationUtils.findAnnotation (e.getClass(), ResponseStatus.class) != null) {
throw e;
}
*/
// Otherwise setup and send the user to a default error-view.
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("url", req.getRequestURL());