日期:2014-05-18 浏览次数:20616 次
public String add(){
String type[]=["10","20","30"];//由页面传递过来,组合为8种checkbox的组合 一个个的if-else太麻烦了
//["10","20","30"]、["10","20"]、["10","30"]、["20","30"]、["10","20","30"]、["10"]、["20"]、["30"]
if(type.equals("10")){
int number = doXXX();
if(number>100){
return "too big";
}else{
list = doXX();
return "something";
}
}else if(type.equals("20")){
int number = doYYY();
if(number>100){
return "too big";
}else{
list = doYY();
return "something";
}
}else if(type.equals("30")){
int number = doZZZ();
if(number>100){
return "too big";
}else{
list = doZZ();
return "something";
}
}else if(type.equals("10,30")){
int number1 = doXXX();
int number2 = doZZZ();
if((number1+number2)>100){
return "too big";
}else{
list = doXX();
list = doZZ();
return "something";
}
}else if(){
......
}
public List<User> add(){
String type[]=s;//由页面传递过来,组合为8种checkbox的组合
//["10","20","30"]、["10","20"]、["10","30"]、["20","30"]、["10","20","30"]
for(String tp:s){
if(tp.equals("10")){
int number = doXXX();
if(number>100){
return "too big";
}else{
list = doXX();
return "something";
}
}
if(tp.equals("20")){
int number = doYYY();
if(number>100){
return "too big";
}else{
list = doYY();
return "something";
}
}
if(tp.equals("30")){
int number = doZZZ();
if(number>100){
return "too big";
}else{
list = doZZ();
return "something";
}
}
}
}