zoukankan      html  css  js  c++  java
  • Java web 5-2 JavaBean+JSP求任意两数代数和

    package beans;

    public class Add {
    private int shuju1;
    private int shuju2;
    private int sum;
    public Add(){}
    public int getShuju1(){return shuju1;}
    public void setShuju1(int shuju1){this.shuju1=shuju1;}
    public int getShuju2(){return shuju2;}
    public void setShuju2(int shuju2){this.shuju2=shuju2;}
    public int getSum(){return shuju1+shuju2;}
    public void getSum(int sum){this.sum=sum;}

    }

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>提交任意2个整数的页面</title>
    </head>
    <body>
    <h3>按下列格式要求,输入两个整数:</h3><br>
    <form action="show.jsp" method="post">
    加数:<input name="shuju1"><br><br>
    被加数:<input name="shuju2"><br><br>
    <input type=submit value="提交">
    </form>
    </body>
    </html>

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>利用JavaBean+JSP求两数和</title>
    </head>
    <body>
    <jsp:useBean id="c" class="beans.Add" scope="request"/>
    <jsp:setProperty name="c" property="*"/>
    <p>调用jsp:getProperty 作标签显示结果值:<br>
    <jsp:getProperty name="c" property="shuju1"/>+
    <jsp:getProperty name="c" property="shuju2"/>=
    <jsp:getProperty name="c" property="sum"/>
    </p>
    </body>
    </html>

    运行:

  • 相关阅读:
    与大神聊天1h
    《海上钢琴师》观后感
    《小王子》读书笔记
    Joining Data with dplyr in R
    SQL学习笔记1
    电影《受益人》观后感
    markdown文本编辑学习笔记2
    importing-cleaning-data-in-r-case-studies
    一个测试人员的工作该怎么开展
    测试总结报告
  • 原文地址:https://www.cnblogs.com/meng2/p/7868885.html
Copyright © 2011-2022 走看看