Skip to content
Snippets Groups Projects
Commit ca7d2eab authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Fixed Spring deprecated method in ErrorController

parent 3514a72b
No related branches found
No related tags found
No related merge requests found
Pipeline #1869 passed
...@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController; import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -27,7 +28,8 @@ public class ErrorController extends AbstractErrorController { ...@@ -27,7 +28,8 @@ public class ErrorController extends AbstractErrorController {
@RequestMapping(produces = MediaType.TEXT_XML_VALUE) @RequestMapping(produces = MediaType.TEXT_XML_VALUE)
public void errorText(HttpServletRequest request, HttpServletResponse response) throws Exception { public void errorText(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> errors = super.getErrorAttributes(request, true); ErrorAttributeOptions options = ErrorAttributeOptions.of(ErrorAttributeOptions.Include.MESSAGE);
Map<String, Object> errors = super.getErrorAttributes(request, options);
response.setContentType("text/plain;charset=UTF-8"); response.setContentType("text/plain;charset=UTF-8");
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
String errorMessage = (String) errors.get("message"); String errorMessage = (String) errors.get("message");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment