zoukankan      html  css  js  c++  java
  • Struts2入门案例——基于Struts2任意两数据的代数和

    //ch11_1_Input.jsp
    <%
    @ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>提交两数据页面</title> </head> <body> <form action="add" method="post"> 请输入两个整数:<br><br> 加数:<input name="x"/><br><br> 被加数:<input name="y"/><br><br> <input type="submit" value="求和"> </form> </body> </html>
    //ch11_1_Positive.jsp
    <%@ page language="java"  pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
      <head>
        <title>显示页面——代数和为非负整数</title>
      </head>
      
      <body>
            代数和为非负整数:<s:property value="sum"/>
      </body>
    </html>
    //ch11_1_Negative.jsp
    <%@ page language="java"  pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
      <head>
        <title>显示页面——代数和为负整数</title>
      </head>
      
      <body>
            代数和为负整数:<s:property value="sum"/>
      </body>
    </html>
    //Ch11_1_Action.java
    package Action;
    
    public class Ch11_1_Action {
        private int x;
        private int y;
        private int sum;
        public int getX() {
            return x;
        }
        public int getY() {
            return y;
        }
        public void setY(int y) {
            this.y = y;
        }
        public int getSum() {
            return sum;
        }
        public void setX(int x) {
            this.x = x;
        }
        public String execute()
        {
            sum=x+y;
            if(sum>=0)
                return "+";
            else
                return "-";
        }    
    }
    <?xml version="1.0" encoding="UTF-8">
    <!DOCTYPE struts PUBLIC
       "-//Apache Software Foundation//DTD Struts Configuration2.3//EN"
        "http://struts.apche.org/dtds/struts-2.3.dtd">
    <struts>
             <package name="default"namespase="/" exetends="struts-default">
                    <action name="add" calss="Action.Ch11_1_Action">
                    <result name="+">/ch11_1_Positive.jsp</result>
                    <result name="-">/ch11_1_Negative.jsp</result>
    </struts>       
  • 相关阅读:
    luogu P2015 二叉苹果树
    luogu P1197 [JSOI2008]星球大战
    QBXT T15214 Day2上午遭遇
    luogu P2831 愤怒的小鸟
    luogu P1018 乘积最大
    [BZOJ2402]陶陶的难题II(树链剖分+线段树维护凸包+分数规划)
    [BZOJ1500][NOI2005]维修数列(splay)
    [BZOJ3282]Tree(LCT)
    [BZOJ4785][ZJOI2017]树状数组(概率+二维线段树)
    [BZOJ2427][HAOI2010]软件安装(Tarjan+DP)
  • 原文地址:https://www.cnblogs.com/liao-pxsoftware15/p/8068234.html
Copyright © 2011-2022 走看看