我有一个servlet,可以在成功创建帐户后将用户重定向到GWT App。
当我使用servlet.getServletContext().getRequestDispatcher(VIEW_APP).forward(request,response);
应用加载的所有内容,但是当我使用response.sendRedirect(VIEW_APP2);
时,应用无法加载。虽然重定向似乎有效,因为我在jsp上有另一个JS脚本加载正常。
有什么可能导致这种情况的想法吗?
来自subscribe servlet的doPost方法:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
/* Some code that validates the account and login the user ommitted for clarity */
if(true){
// response.sendRedirect(VIEW_APP2);// what doesn't work
servlet.getServletContext().getRequestDispatcher(VIEW_APP).forward(request,response);
}else{
servlet.getServletContext().getRequestDispatcher(VIEW_LOGIN_FORM).forward(request,response);
}
}
我使用的网址VIEW_APP="/restricted/plan.jsp";
和VIEW_APP2="/restricted/plan";
jsp:
<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<meta name="gwt:property" content="locale=en">
<title>Title</title>
<link type="text/css" rel="stylesheet" href="inc/restricted.css" />
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<script type="text/javascript" language="javascript" src="proto2/proto2.nocache.js"></script>
</head>
<body>
<div id="stockList"></div> <!-- the div I am trying to load-->
<div><a href="javascript:HelloWorld()">Hello</a></div><!-- a dummy function-->
</body>
<script type="text/javascript">
function HelloWorld(){alert ("Hello World!");}
</script>
当我使用重定向时,带有虚拟js函数的div加载正常但不是gwt app proto2 / proto2.nocache.js