• 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>       
  • 相关阅读:
    12306站点推出图片验证 反破解
    android自己定义控件之飞入飞出控件
    ORACLE 从一个实例迁移到另外一个实例实战记录
    通信协议:HTTP、TCP、UDP
    先打11.2.0.3.8这个PSU,后建库
    C# 多线程參数传递
    运维笔记10 (Linux软件的安装与管理(rpm,yum))
    为RecyclerView打造通用Adapter
    大话设计模式(四)单例模式
    Java代码质量监控工具Sonar安装
  • 原文地址:https://www.cnblogs.com/liao-pxsoftware15/p/8068234.html
Copyright © 2020-2023  润新知