日期:2014-05-18  浏览次数:20822 次

JavaBean..跳转页面变加法怎么办呢?
package   cn.ac.ict;
public   class   SumM{
                   
                      private   String   sumcost;
                          //定义sumcost为私有变量
public   SumM(){
}
                          //SumM属性的设置方法

public   void   setSumcost(String   scost)
{
sumcost=scost;
}
//sumcost属性的获取方法

public   String   getSumcost(){
return   sumcost;
}
     
    }

这样写的一个JAVABEAN...不过有点小问题..


<%@   page   language= "java "   pageEncoding= "GB2312 "   %>
<%@   page   import= "java.sql.*,cn.ac.ict.* "   %>
<jsp:useBean   id= "user_1 "   class   = "cn.ac.ict.UserInfo "   scope= "session "/>

<jsp:useBean   id= "user_2 "   class   = "cn.ac.ict.UserInfo "   scope= "session ">

</jsp:useBean>

<jsp:setProperty   name= "user_2 "   property= "username "   value= "zhw "/>
<!DOCTYPE   HTML   PUBLIC   "-//w3c//dtd   html   4.0   transitional//en ">
<html>
<head>
<title> JavaBean的测试 </title>
</head>
<body   bgcolor= "#FFFFFF ">
<form   action= "cgi-bin\testcgi "   method= "post ">
<p> a: <input   type= "text "   name= "a1 "   maxlength= "25 "> </p> <br>
<p> b: <input   type= "text "   name= "a2 "   size= "15 "> </p> <br>
<a   href= "javabeantest.jsp "   >   <input   type= "submit "   value= "确认 "     > </a> <br>
<%=user_1.getUsername()%> + <%=user_1.getUsername()%> = <%=( <%=user_1.getUsername()%> <%=user_1.getUsername()%> )%>
</body>
</html>

这样子为什么不能跳转过去自动运算呢?有人帮我解决下嘛.

------解决方案--------------------
因为你少写了 </form>
<input type= "submit " value= "确认 "> 只会对所在的form进行提交