I have the following controller:
@Controller
public class MyErrorController implements ErrorController {
@RequestMapping("/error")
public String handleError(HttpServletRequest request, Model model) {
model.addAttribute("request", request);
return "error";
}
}
And the following template:
URL: <span th:text="${#request.getRequestURL()}">url</span><br/>
If I go to the url http://localhost:8080/this-is-a-404-url
, here is what the template shows:
URL: http://localhost:8080/error
However, this is not the correct url (it's only the requestMapping). Is there a way to get the client url from the request
object in the template?
Note, if I had to do this in the controller, I would do: request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
. Is there a way to do that in thymeleaf?