<%@ page import="java.util.*"%>
<%!String functionNo=null;%>
<jsp:useBean id="createGroup" class="com.gdcn.admin.Group" scope="request">
<jsp:setProperty name="createGroup" property="*"/>
</jsp:useBean>
<%
int groupLayer =ParamUtils.getIntParameter(request,"groupLayer",0);
long parentID = ParamUtils.getIntParameter(request,"parentID",0);
boolean insert = ParamUtils.getBooleanParameter(request,"insert",false);
String ref = request.getHeader("REFERER");
Group group = new Group();
if(insert){
   createGroup.setParentID(parentID);
GroupMana.createGroup(createGroup);
response.sendRedirect("group2.jsp?groupID=1");
}
%>
<html>
<head>
<title>创建单位</title>
<script language="javascript" type="text/javascript">

function checkdata(){
var groupname=document.getElementById("groupName").value;
if(groupname ==""){
alert("单位/组织名称不能为空!");
return false;
}else{
document.getElementById("insert").value="true";
     form1.submit();
     }
}
</script>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<link href="../css.css" rel="stylesheet" type="text/css">
<body topmargin="0" leftmargin="0"> 
<br> 
<form name="form1" method="post" action=""> 
  <table border="0" width="90%" cellspacing="0" cellpadding="0" align=center> 
    <tr> 
      <td height="22" valign=top background="" colspan="2" nowrap >
       创建新<font color="blue"><%=GroupMana.getLayerName(groupLayer)%></font>,红星(<font color="#FF0000">*</font>)是必填。 </td> 
    </tr> 
    <tr> 
      <td  nowrap  align="right"  height="22" valign=top background="">
       <font color="red">*</font><font color="blue"><%=GroupMana.getLayerName(groupLayer)%></font>名称:</td> 
      <td nowrap align="left"  height="22" valign=top background=""> 
      <input name="groupName" type="text" id="groupName" value=""/> </td> 
    </tr> 
    <tr> 
      <td  align="right" valign="top" nowrap height="22" background="">组织类型:</td> 
      <td  align="left" height="22" valign=top background="">
      <select name="typeID">
          <% for (int i=0;i<ConstantManager.getGroupType().length;i++){ 
          %> 
          <option value="<%=i%>" <%=group.getTypeID()==i ? "selected":""%>>
           <%=ConstantManager.getGroupType(i)%>
          </option> 
          <% } %> 
        </select></td> 
    </tr>     <tr> 
      <td height="45" colspan="2" align="center" bgcolor="#ffffff"> <br> 
        <input type="button" value="创建" onclick="javascript:checkdata()"/>&nbsp; &nbsp;&nbsp; &nbsp;  
        <input type="reset" name="Submit2" value=" 重置 " class="newinput"/> &nbsp;&nbsp; 
        <input type="button" name="Submit3" value=" 返回 " class="newinput" onclick="javascript:window.location='<%=ref%>'"/>  
       </td> 
    </tr> 
  </table> 
<input type="hidden" name="groupLayer" value="<%=groupLayer%>"/> 
<input type="hidden" name="parentID" value="<%=parentID%>"/> 
<input type="hidden" name="insert" value="false"/> 
</form> 
</body>
</html>

解决方案 »

  1.   

    1.jsp里定义了以个输入域<input name="groupName" type="text" id="groupName" value=""/>
    2.我想通过
    <jsp:useBean id="createGroup" class="com.gdcn.admin.Group" scope="request"> 
    <jsp:setProperty name="createGroup" property="*"/> 
    </jsp:useBean> 
    来取得它的值
    3.但是执行GroupMana.createGroup(createGroup); 的时候,createGroup拿到的Groupname值却不对
      

  2.   

    本帖最后由 AWUSOFT 于 2009-05-25 14:26:44 编辑
      

  3.   

    注意属性名要规范,应该和页面上的text名称一样.大小写也一样..类里的get/set方法也要按规范来做
    groupName;
    getGroupName()
    setGroupName(String)
    看看你的类里有没有这样的方法