[英]response.sendRedirect() doesn't redirect properly
I have a response.sendRedirect()
in an if
statement, linking to a link generated by string.format
: 我在if
语句中有一个response.sendRedirect()
,链接到string.format
生成的链接:
String redirect = String.format("booking?order_id=%d&complete='0'&date='%s'&timePeriod='%s'&totalPrice=%d", intBookingID, date, timePeriod, intTotalPrice);
however this generates a 500 error instead or linking to the requested page, is this because I have used parameters, and If so how else would I do this? 但这会产生500错误或链接到请求的页面,这是因为我使用了参数,如果是这样,我怎么办呢?
它需要添加/your-web-context/
ahead所需的绝对地址
What are you doing with the string redirect
? 你在用字符串redirect
做什么? You should call HttpServletResponse.sendRedirect()
but you must not call setStatus()
, setContentType()
, setContentLength()
, setCharacterEncoding()
, getOutputStream()
or getWriter()
on the HttpServletResponse
before or after sendRedirect()
as the API says: 你应该调用HttpServletResponse.sendRedirect()
但是你不能在sendRedirect()
之前或之后在HttpServletResponse
上调用setStatus()
, setContentType()
, setContentLength()
, setCharacterEncoding()
, getOutputStream()
或getWriter()
,因为API说:
If the response has already been committed, this method throws an IllegalStateException. 如果响应已提交,则此方法将抛出IllegalStateException。
Is there any additional message in the 500 error page or in the log of the server? 500错误页面或服务器日志中是否还有其他消息? 500 (Internal Server Error) is typically an uncaught exception. 500(内部服务器错误)通常是未捕获的异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.