在做计算器时怎样使“+”按钮有相加的功能?
解决方案 »
- REST风格的项目部署在tomcat上,静态资源如何访问
- J2EE 1.5或者1.4 中文版API
- hibernate的HQL语言错误
- OA 公文流转流程设计,望有经验的大牛提建议...
- hibernate 与sql server 2000中文问题
- 招聘银行项目 JAVA 软件工程师!
- eclipse 构建路径问题!求指导 无法解析类型 java.lang.Object
- apache tomcat 5.0.27
- STRUTS框架中,如何从数据库表中取数据(100条)?300分
- ejb中的实体bean要不要实现查找方法 “select * from name where name='name'"
- 数据库
- 谁遇到过 seasar/sqlJdbc 出异常:resultSet = null
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;// TODO Auto-generated method stub
Calc calc = new Calc();
String num1 = userForm.getNum1();
String num2 = userForm.getNum2();
ActionMessages mes = new ActionMessages();
if(!this.calcNum(num1)){
mes.add("num1", new ActionMessage("num1只能为数字",false));
}
if(!this.calcNum(num2)){
mes.add("num2", new ActionMessage("num2只能为数字",false));
}
if(!mes.isEmpty()){
saveErrors(request, mes);
return mapping.getInputForward();
}
double a = Double.parseDouble(num1);
double b = Double.parseDouble(num2);
double sum = calc.add(a, b);
request.setAttribute("sum", sum);
return mapping.findForward("show");
}<html>
<head>
<title>JSP for UserForm form</title>
<script type="text/javascript">
function check(method){
document.userForm.m.value = method;
document.userForm.submit();
}
</script>
</head>
<body style="margin-top: 135px">
<center>
<html:form action="/user">
<input type="hidden" name="m"/>
数字1 : <html:text property="num1"/><html:errors property="num1"/><br/>
数字2 : <html:text property="num2"/><html:errors property="num2"/><br/>
<html:button property="add" value="加" onclick="check('add')"></html:button>
<html:button property="sub" value="减" onclick="check('sub')"></html:button>
<html:button property="mul" value="乘" onclick="check('mul')"></html:button>
<html:button property="div" value="除" onclick="check('div')"></html:button>
</html:form>
</center>
</body>
</html>
http://topic.csdn.net/u/20090901/11/f4166c4b-aad4-4e3c-a839-0e96cf6ce9e1.html
楼主,对你我是彻底无语了