从上一页面传进一参数 参数名为customer_id,参数值未知,请在一个JSP文件中写出代码实现如下功能:
页面含有文本框和按钮两个表单元素,当点击按钮之后,在文本框中显示传进的参数值,且当参数值不为空或null时跳转到另一JSP页面并传出参数,否则弹出提示 

解决方案 »

  1.   

    如何在当前页面取得customer_id的值用javaScript吗?
      

  2.   

    直接<% %>写JAVA代码 从request里面取就行了
      

  3.   

    html获取参数,并跳转会吗?jsp里面也是一样的。
      

  4.   

    假设 前一个页面的传入url是  http://localhost:8080/test/test.jsp?customer_id=3
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head><title>test.jsp</title></head>
      <%
          String customerid=  request.getParameter("customer_id")   ;      if(customerid ==null){
              customerid ="";
          }
      %>
      <script>
          var  customerid ="<%=customerid%>"  ;         function setValue(){
               if(customerid==""){
                   alert("传入参数为空 请检查");
               }else {
                   document.getElementById("test").value=  customerid;
                   if(confirm("请问需要跳转至其他页面吗")){
                       window.open("http://localhost:8080/test/otherjsp.jsp?customer_id="+customerid)
                   }
               }
             }
      </script>
      <body><input type="text" id="test" name="test"><input type="button" value="设置" onclick="javascript:setValue();"> </body>
    </html>