Udit003
10/24/2018, 2:36 PMfun serveRequest(response :HttpServletRes) : ResponseObject? {
if(condition_satisfied) {
response.status = HttpServletResponse.SC_MOVED_PERMANENTLY
response.sendRedirect("/new_path")
return null
} else {
return Responsebject()
}
}
This gives me 2 problems :
1. even if the response status is explicitly set 301 , it returns 302
2. The code looks a bit "hacky" to me, getting a feeling that better code can be possible.diesieben07
10/24/2018, 2:40 PMResponseBody
, make your return type Any
(Spring does not actually care what the static type is), then you can return both ResponseEntity<ResponseObject>
and a String (redirect:/new_path
).Udit003
10/24/2018, 2:42 PMdiesieben07
10/24/2018, 2:57 PMUdit003
10/24/2018, 2:59 PMdiesieben07
10/24/2018, 2:59 PMUdit003
10/24/2018, 3:01 PMdiesieben07
10/24/2018, 3:02 PMUdit003
10/24/2018, 3:05 PMdiesieben07
10/24/2018, 3:08 PMUdit003
10/24/2018, 3:11 PMnfrankel
10/24/2018, 4:43 PM