要求输入两个数,只输入一个,返回一个需要修改的提示
要求输入两个数,只输入一个,返回一个提示public class AddAction extends DispatchAction {
public ActionForward doAdd(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
Calculator calc = new Calculator();
//获得ActionForm的引用
AddForm addForm = (AddForm) form;
double model = calc.Add(
Double.parseDouble(addForm.getFirstNumber()),Double.parseDouble(addForm.getSecondNumber()) );
//将计算结果存储到request中
if(addForm.getFirstNumber()== null){
String a ="you should input something";
request.setAttribute("sum",a);
return mapping.findForward("result");
}
else{
String a = String.valueOf(model);
request.setAttribute("sum", a);
//将请求转发到"result"出口指向的页面
return mapping.findForward("result");
}
}
谁能告诉我怎么改?没有报错 就是实现不了结果