【问题标题】:JSP - Pass a variable to servletJSP - 将变量传递给 servlet
【发布时间】:2013-03-22 07:46:22
【问题描述】:

如何将 value=x 从 JSP 传递给 servlet?我搜索了许多相关问题,但无法得到答案。 这里 x 是一个变量。

<html>
<body>
<%@ page import="java.lang.*"%>
<%!int x,y; %>
<% String a,b;
a=request.getParameter("jobs");
b=request.getParameter("process");
x=0;
y=0;
try
{
 x=Integer.parseInt(a);
   y=Integer.parseInt(b);
}
catch(Exception e)
{ }
  out.println("You selected - <br>");
  out.println("Jobs - "+x+"<br>");
  out.println("Process - "+y);
   String path="table?input=x";
   %>

  <jsp:include page="table" > 
   <jsp:param name="input"  value=x/>
  </jsp:include>

</body>
</html>

【问题讨论】:

    标签: java jsp variables include


    【解决方案1】:

    由于变量 x 在 scriptlet 中,您需要使用

    <jsp:include page="table" > 
        <jsp:param name="input"  value="<%=x%>"/>
    </jsp:include>
    

    【讨论】:

    • 工作完美!!谢谢。
    猜你喜欢
    • 1970-01-01
    • 2014-09-03
    • 2012-03-18
    • 2013-06-10
    • 2011-04-06
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    • 1970-01-01
    相关资源
    最近更新 更多