0

私はこのコードを持っています:

    <script type="text/javascript">
    var endpoint = "http://localhost:8080/LWP/in.jsp?code=" + "<% out.println(request.getParameter("code")); %>";

    window.opener.location.href = endpoint;

    window.close();
    </script>

私が期待しているのは、これが処理しているブラウザウィンドウを開いたページをリダイレクトすることです

http://localhost:8080/LWP/in.jsp?code=<code here>

スクリプトの <% out.println() %> 部分を削除すると、正常に動作し、期待どおりにリダイレクトされます (渡される値を除く)。

パラメータの出力で間違っていることは何ですか?

out.println も削除してみました。それでも機能しません。

4

1 に答える 1

0

理解した。値を新しい変数に割り当ててから、それを使用する必要がありました。

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% String code = request.getParameter("code"); %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <script type="text/javascript">
    var code = "<%=code%>";
    var endpoint = "http://localhost:8080/LWP/in.jsp?code=" + code;

window.opener.location.href = endpoint;

window.close();
    </script>
</head>
<body>

</body>
</html>
于 2013-05-01T19:50:52.220 に答える