美文网首页JSP专题
通过request对象进行数据传递

通过request对象进行数据传递

作者: 神坛下的我 | 来源:发表于2018-08-17 15:53 被阅读0次

index.jsp

<body>
    <%
        try{
            int money=100;
            int number=50;
            request.setAttribute("money", money);
            request.setAttribute("number",number);
            request.setAttribute("result", money/number);
        }catch(Exception e){
            request.setAttribute("result", "Sorry,Page hava a error.");
        }
    %>
    <jsp:forward page="result.jsp"/>
</body>

result.jsp

<body>
    <%String message=request.getAttribute("result").toString(); %>
    <%=request.getAttribute("money")%>除以<%=request.getAttribute("number")%>等于<%=message %>
</body>
10.PNG

相关文章

网友评论

    本文标题:通过request对象进行数据传递

    本文链接:https://www.haomeiwen.com/subject/lfhtiftx.html