Struts2框架——基于struts2计算任意两个数据的和

Struts2框架——基于struts2计算任意两个数据的和_第1张图片

 

package model;

public class Add {
	double x;
	double y;
	double sum;
	public double getX() {
		return x;
	}
	public void setX(double x) {
		this.x = x;
	}
	public double getY() {
		return y;
	}
	public void setY(double y) {
		this.y = y;
	}
	public double getSum() {
		return x+y;
	}
	
	

}
package action;

import model.Add;

public class AddAction {
	private Add add;

	public Add getAdd() {
		return add;
	}

	public void setAdd(Add add) {
		this.add = add;
	}

	public AddAction() {
	}
	
	public String executeAdd() {
		String ff=null;
		if(add.getSum()<0) {
			ff="-";
		}else {
			ff="+";
		}
		return ff;
		
	}
	
	

}





   
   
   positive.jsp
   negative.jsp
   
   
   




  struts 2
  
        struts2
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    

    
        struts2
        /*
    
 
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


加数: 被加数:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import= "model.Add" %>




Insert title here


<%Add add=null; %>
fushu:${add.x}+${add.y}=$add.sum}


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
     <%@ page import= "model.Add" %>




Insert title here


<%Add add=null; %>
zhengshu :${add.x}+${add.y}=$add.sum}


 

你可能感兴趣的:(javaee,框架)