开发者

Javascript redirect

I am working with javascript and here is what I am trying to do: 1. Send a get request which looks like "http://开发者_如何学Pythonlocalhost:8080/myapp/verify.htm?verifyId=Agkvhs"

My requests reaches my verify.jsp in which I have javascript which does some special things and then should redirect to another url WITH the verifyId . My code looks like this:

function saveAndRedirect() {
    var verifyId = "<%=request.getParameter("verifyId")%>";
    var redirectUrl = "registrationVerify?verifyId=" + verifyId;
    window.alert("Got value " + redirectUrl);
    window.location = redirectUrl;

}

However this does not work. I have an alert which shows me the correct URL with the appended parameter as I expect. In my web.xml file I have a servlet mapping with the following:

 <servlet-mapping>
     <servlet-name>RegistrationVerificationServlet</servlet-name>
     <url-pattern>/registrationVerify*</url-pattern>
 </servlet-mapping>

This mapping was workign before I appended the verifyId to the URL, I could see my request beign redicted to the servlet, since I appended this param it is not working. Any ideas much appreciated!

If this is not the ideal way to do this, please let me know any alternative.

Thanks


Your url-pattern is suspicious.

Use either

/registrationVerify

to cover the exact path or

/registrationVerify/*

to cover the part of pathinfo. Note that you don't explicitly need the last one to be able to accept request parameters, if you'd thought that.


This is a bit of a long-shot, but does this line change help?

window.location=window.location.href+redirectURL;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜