当前位置: 代码迷 >> Java Web开发 >> jsp页面初始化的有关问题,进入不去,大神指点一下
  详细解决方案

jsp页面初始化的有关问题,进入不去,大神指点一下

热度:58   发布时间:2016-04-13 22:40:05.0
jsp页面初始化的问题,进入不去,大神指点一下!
 就是user==null,return "list";。进不去userDao.selcetall方法。我估计是在JSP里面出问题,但是看了半天不懂怎么解决,大神帮忙解决一下

ACTION
public String list(){
if(this.getPage()==null){
this.setPage(new Page());
}

List<Gjt_User>list=new ArrayList<Gjt_User>();

if (user!=null) {
System.out.println("...................进入到useraction");
Map<String, Object> param=new HashMap<String, Object>();
param.put("username", user.getUsername());
param.put("userphone", user.getUserphone());
list=userDao.selcetall(param);

this.page.setTotalRows(userDao.count(param));
param.put("page", this.page);
list=userDao.selcetall(param);

request.setAttribute("list", list);
}

return "list";

JSP
<body>
<form name="fom" id="fom" method="post" action="${pageContext.request.contextPath }/user_list.do">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>
    <td height="30">
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="62" background="../images/nav04.gif">
          
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
<td width="21"></td>
<td width="300">按用户名查询:
 <input name="" type="text" size="12" />
  <s:submit cssClass="right-button02" value="查询"></s:submit>
 </td>
</table></td>
  </tr>
  <tr>
    <td><table id="subtree1" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        
              <tr>
                <td height="40" class="font42"><table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">


                  <tr>
<td width="10%" height="20" align="center" bgcolor="#EEEEEE">用户名</td>
                    <td width="10%" align="center" bgcolor="#EEEEEE">所属部门</td><!--
                    <td width="10%" align="center" bgcolor="#EEEEEE">对应权限</td>
                     --><td width="9%" align="center" bgcolor="#EEEEEE">姓名</td>
                    <td width="5%" align="center" bgcolor="#EEEEEE">性别</td>
                    <td width="6%" align="center" bgcolor="#EEEEEE">年龄</td>
                    <td width="10%" align="center" bgcolor="#EEEEEE">电话</td>
                    <td width="15%" align="center" bgcolor="#EEEEEE">邮箱</td></tr>
                    <s:iterator value="#request.list" var="user" status="states">
                  <tr>
   <td height="20" bgcolor="#FFFFFF"><div align="center">   <s:property value="#user.id"/></div></td>
                    <td height="20" bgcolor="#FFFFFF"><div align="center">   <s:property value="#user.username"/></div></
                  </tr>
  </s:iterator>
                </table></td>
              </tr>
            </table></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="6"><img src="../images/spacer.gif" width="1" height="1" /></td>
          <s:include value="/common/pager.jsp"></s:include>
        </tr>
        <tr>
        </tr>
      </table>
     </td>
  </tr>
</table>
</td>
</tr>
</table>

</form>
</body>

------解决思路----------------------
传参的问题  没有给action传参
将  <input name="" type="text" size="12" />   name的值 设为 user.userName  
而且 你还哟保证你的action 类中 有 user 的get/set  方法
  相关解决方案