Ext+spring+dwr查询数据库的值无法显示

yinhao131415 2008-03-05
各位大哥,帮我看看一下,这个Ext+dwr+spring的问题.我搞了大半天,一直没有找出问题的根源.
希望大家能帮我找出问题来

数据库:uYou

if exists(select * from sysobjects where name='users')
drop table users
go
create table users
(
uid int identity(1,1) primary key,
usex varchar(4),
uname varchar(10),
uremark varchar(20)
)
go
insert into users values('男','郭靖','九阴真经')
insert into users values('女','黄蓉','平沙落雁掌')
insert into users values('男','杨过','暗然销魂掌')
insert into users values('女','小龙女','玉女心经')
insert into users values('男','洪七公','降龙十八掌')
insert into users values('男','东邪','劈空掌')


index.jsp页面;


<link rel="stylesheet" type="text/css"
href=" <%=basePath%> css/ext-all.css">
<script type="text/javascript" src=" <%=basePath%> ext/ext-base.js"> </script>
<script type="text/javascript" src=" <%=basePath%> ext/ext-all.js"> </script>
<script type="text/javascript" src=" <%=basePath%> ext/dwrproxy.js"> </script>
<script type='text/javascript' src='/MyLastExt/dwr/interface/hello.js'> </script>
<script type='text/javascript' src='/MyLastExt/dwr/engine.js'> </script>
<script type='text/javascript' src='/MyLastExt/dwr/util.js'> </script>


<script type="text/javascript">
Ext.onReady(function(){
function formatSex(value){
if(value=='male'){
return " <span style='color:red;font-weight:border'> 红男 </span> ";
}else{
return " <span style='color:green;font-weight:border'> 绿女 </span> ";
}
}

    var cm= new Ext.grid.ColumnModel([
{id:'descn',header:'描述',dataIndex:'descn'},
        {id:'id',header:'编号',dataIndex:'id',sortable:true},
        {id:'name',header:'名称',dataIndex:'name'},
        {id:'sex',header:'性别',dataIndex:'sex',renderer:formatSex}

     ]);

 
var recordType=Ext.data.Record.create([
            {name: 'id',mapping:'id',type:'int'},
            {name:'sex',mapping:'sex',type:'string'},
            {name: 'name',mapping:'name',type:'string'},
            {name: 'descn',mapping:'descn',type:'string'}
        ]);
        
  
     
   var ds = new Ext.data.Store({
         proxy: new Ext.data.DWRProxy(hello.getUserInfo, true),
          reader: new Ext.data.ListRangeReader({
             totalProperty: 'totalSize',
             id: 'id'}, recordType),
               remoteSort:true
     });

    

  ds.load();
    var grid = new Ext.grid.GridPanel({
    el:'grid',
    ds:ds,
    cm:cm,
    bbar:new Ext.PagingToolbar({
     pageSize:10,
     store:ds,
     displayInfo:true,
     displayMsg:'显示第一页的数据',
     empty:'没有任何记录'
    })
});
     grid.render();
});
</script>


<div id="grid" style="height:400px;width:400px"> </div>


dwr.xml里面的配置;

<allow>
<create javascript="hello" creator="spring">
<param name="beanName" value="getuser"> </param>
<include method="getUserInfo"/>
<include method="getUsers"/>
</create>

<convert converter="bean" match="com.hotel.UserInfo">
<param name="include" value="id,name,sex,descn" > </param>
</convert>
<convert match="com.hotel.ListRange" converter="bean">
<param name="include" value="data[],totalSize"> </param>
</convert>

</allow>

  <signatures>
   <![CDATA[
  import java.util.List;
  import com.hotel.GetConnection;
  import com.hotel.UserInfo;
  import com.hotel.ListRange;
  ]]>
   </signatures>


applicationContext.xml中的配置;

<bean id="getuser" class="com.hotel.GetConnection"> </bean>


后台的代码如下了GetConnection.java


public ListRange getUserInfo(){
ListRange list=new ListRange();
conn=this.getConn();
Statement st;
try {
st = conn.createStatement();
ResultSet rs=st.executeQuery("select * from users");
List resule=new ArrayList();
UserInfo user=null;
while(rs.next()){
user=new UserInfo();
user.setId(rs.getInt("uid"));
user.setSex(rs.getString("usex"));
user.setName(rs.getString("uname"));
user.setDescn(rs.getString("uremark"));
resule.add(user);
}
list.setData(resule.toArray());
list.setTotalSize(resule.size());
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}finally{
}

}

ListRange.java文件的代码:
import java.io.Serializable;

public class ListRange implements Serializable
{

 public ListRange()
 {
 }

 public Object[] getData()
 {
     return data;
 }

 public void setData(Object data[])
 {
     this.data = data;
 }

 public int getTotalSize()
 {
     return totalSize;
 }

 public void setTotalSize(int totalSize)
 {
     this.totalSize = totalSize;
 }

 private static final long serialVersionUID = 1L;
 private Object data[];
 private int totalSize;
}


希望各位大哥们帮忙解决一下。源码都放在附件里面。可以下下来看的。