Emerjoin / Hi-Framework-features

Java EE Framework
5 stars 1 forks source link

Get parameters mapping #127

Open Emerjoin opened 7 years ago

Emerjoin commented 7 years ago

Why to we need Get parameters mapping?


@Mapping("/order")
public class OrderController extends Controller {     

     public void cancel(@Map("id") String id) throws MvcException{
          this.callView();
     }      

     public void pay(@Map("id") String id, @Map("amt") Optional<Double> amount) {

           if(amount.isPresent){
                      double amt = amount.get();
                     //Do partial payment here
            }else{        
                 //Do full payment here
           }

    }

}

The action order/pay would return 200 for the following invocation

GET order/pay?id=10&amt=1200 //The values match the  declared types

It would return 404 for the following invocations

GET order/pay?id=10&amt=abc //The amt value is not a valid double