大侠们花点宝贵的时间帮忙看下把 先谢过了
O/R<sqlMap namespace="Ad"> <typeAlias alias="ad" type="com.ceno.smile.domain.Ad" />
<select id="getAdListForPage" resultClass="ad" >
SELECT * FROM ad
</select>public PaginatedList getAdListForPage() {
return queryForPaginatedList("getAdListForPage", null, 5);
}private int id;
private Ad ad;
private AdService adService;
private PaginatedList adList;
private PageBean pageBean;
private String pageDriection;
private String gotoPage;
private int pageJump;
private List<Integer> pageJumpList;
.......省略
public String getAdListForPage() {
try {
adList = adService.getAdListForPage();
System.out.println(adList);
pageBean.setPageSize(adList.getPageSize());
pageBean.setNowPage(adList.getPageIndex() + 1);
pageBean.setTotalRecored(adService.getAdCount());
setMessageOfSession("adList", adList);
setMessageOfSession("pageBean", pageBean);
pageJumpList();
} catch (Exception e) {
e.printStackTrace();
System.out.println(adList);
}
return SUCCESS;
}<form-beans>
<form-bean name="testBean" type="com.ceno.smile.presentation.testBean"></form-bean>
<form-bean name="adBean" type="com.ceno.smile.presentation.AdBean"></form-bean>
</form-beans><action path="/admin/getAdListForPage" type="org.apache.struts.beanaction.BeanAction"
name="adBean" scope="session" validate="false">
<forward name="success" path="/admin/Advert_Manage.jsp" />
<forward name="failure" path="/test/failure.jsp" />
</action> <logic:iterate id="adList" name="adList">
<tr>
<td class=td1 align="center" >
<input name='ID' type='checkbox' id="ID" value='398'></td>
<td class=td2 align="center"><a href="admin.html?id=1&action=pasword">${adList.id }</a></td>
<td align="center" class=td1>${adList.adTitle }</td>
<td class=td2 align="center">${adList.type }</td>
<td class=td1 align="center" ><bean:write name="adList" property="addTime" format="yyyy-MM-dd"/></td>
<td class=td2 align="center"><a href="#" onClick="{if(confirm('删除后不可恢复!\n\n确定删除吗?')){return true;}return false;}">删除</a> <a href="Advert_Modi.html">修改</a> <a href="Advert_Check.html">审核</a></td>
</tr>
</logic:iterate>错误com.ibatis.dao.client.DaoException: Failed to queryForPaginatedList - id [getAdListForPage], parameterObject [null], pageSize [5]. Cause: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ceno/smile/persistence/sqlmapdao/sql/ad.xml.
--- The error occurred while applying a result map.
--- Check the getAdListForPage-AutoResultMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ceno/smile/persistence/sqlmapdao/sql/ad.xml.
--- The error occurred while applying a result map.
--- Check the getAdListForPage-AutoResultMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
at com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForPaginatedList(SqlMapDaoTemplate.java:274)
at com.ceno.smile.persistence.sqlmapdao.AdSqlMapDao.getAdListForPage(AdSqlMapDao.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/Advert_Manage.jsp at line 3128: <td width="17%" class="td2"><B>操作</B></td>
29: </tr>
30:
31: <logic:iterate id="adList" name="adList">
32: <tr>
33: <td class=td1 align="center" >
34: <input name='ID' type='checkbox' id="ID" value='398'></td>javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean adList in any scope
O/R<sqlMap namespace="Ad"> <typeAlias alias="ad" type="com.ceno.smile.domain.Ad" />
<select id="getAdListForPage" resultClass="ad" >
SELECT * FROM ad
</select>public PaginatedList getAdListForPage() {
return queryForPaginatedList("getAdListForPage", null, 5);
}private int id;
private Ad ad;
private AdService adService;
private PaginatedList adList;
private PageBean pageBean;
private String pageDriection;
private String gotoPage;
private int pageJump;
private List<Integer> pageJumpList;
.......省略
public String getAdListForPage() {
try {
adList = adService.getAdListForPage();
System.out.println(adList);
pageBean.setPageSize(adList.getPageSize());
pageBean.setNowPage(adList.getPageIndex() + 1);
pageBean.setTotalRecored(adService.getAdCount());
setMessageOfSession("adList", adList);
setMessageOfSession("pageBean", pageBean);
pageJumpList();
} catch (Exception e) {
e.printStackTrace();
System.out.println(adList);
}
return SUCCESS;
}<form-beans>
<form-bean name="testBean" type="com.ceno.smile.presentation.testBean"></form-bean>
<form-bean name="adBean" type="com.ceno.smile.presentation.AdBean"></form-bean>
</form-beans><action path="/admin/getAdListForPage" type="org.apache.struts.beanaction.BeanAction"
name="adBean" scope="session" validate="false">
<forward name="success" path="/admin/Advert_Manage.jsp" />
<forward name="failure" path="/test/failure.jsp" />
</action> <logic:iterate id="adList" name="adList">
<tr>
<td class=td1 align="center" >
<input name='ID' type='checkbox' id="ID" value='398'></td>
<td class=td2 align="center"><a href="admin.html?id=1&action=pasword">${adList.id }</a></td>
<td align="center" class=td1>${adList.adTitle }</td>
<td class=td2 align="center">${adList.type }</td>
<td class=td1 align="center" ><bean:write name="adList" property="addTime" format="yyyy-MM-dd"/></td>
<td class=td2 align="center"><a href="#" onClick="{if(confirm('删除后不可恢复!\n\n确定删除吗?')){return true;}return false;}">删除</a> <a href="Advert_Modi.html">修改</a> <a href="Advert_Check.html">审核</a></td>
</tr>
</logic:iterate>错误com.ibatis.dao.client.DaoException: Failed to queryForPaginatedList - id [getAdListForPage], parameterObject [null], pageSize [5]. Cause: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ceno/smile/persistence/sqlmapdao/sql/ad.xml.
--- The error occurred while applying a result map.
--- Check the getAdListForPage-AutoResultMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ceno/smile/persistence/sqlmapdao/sql/ad.xml.
--- The error occurred while applying a result map.
--- Check the getAdListForPage-AutoResultMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of '<[3titlecnull]>'. Cause: java.lang.IllegalArgumentException
Caused by: java.lang.IllegalArgumentException
at com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForPaginatedList(SqlMapDaoTemplate.java:274)
at com.ceno.smile.persistence.sqlmapdao.AdSqlMapDao.getAdListForPage(AdSqlMapDao.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/Advert_Manage.jsp at line 3128: <td width="17%" class="td2"><B>操作</B></td>
29: </tr>
30:
31: <logic:iterate id="adList" name="adList">
32: <tr>
33: <td class=td1 align="center" >
34: <input name='ID' type='checkbox' id="ID" value='398'></td>javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean adList in any scope
解决方案 »
- 使用的是SSH框架,想问一下如何可以实现文档的在线浏览?
- 新手请教Struts中jsp页面如何发送给Action汉字,不至于出现乱码。
- apache+tomcat,apache经常出问题,原因大概在哪里呢
- 如何将xml转换成excel
- 很奇怪的一个hibernate问题
- 在“Generating Artifacts”期间发生了内部错误。哪位高手能帮我看看!
- JavaMail邮件解析问题!(给高分100)
- Unix下压缩.z文件
- hibernate 为什么只能调用master数据库的存过程
- 大量急需J2EE开发人才!!!!
- java 如果获取两个特定字符之间的字符串
- 男人的忍耐到顶了,一定要解决linux环境中文乱码的问题,请各位大哥大嫂指教
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wellhope.struts2mybatis.model.UsersMapper">
<resultMap type="Ele" id="ele">
<!--
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="name" column="name" javaType="string"
jdbcType="VARCHAR" /> <result property="sex" column="sex"
javaType="string" jdbcType="VARCHAR" />
-->
</resultMap>
<resultMap type="Users" id="user">
</resultMap> <!-- 查询单一对象所有属性 -->
<select id="selectUsers" parameterType="int" resultType="Users">
select
id,name,age,email from employee where id = #{id}
</select>
<!-- 查询总记录数 -->
<select id="selectAllNumber" parameterType="Ele" resultType="int">
select count(1) from employee
<where>
<if test="usName!=null">
And name=#{usName}
</if>
<if test="usAge!=null">
And age=#{usAge}
</if>
<if test="usEmail!=null">
And email=#{usEmail}
</if>
</where>
</select>
<!-- 查询表所有属性 -->
<select id="selectAll" parameterType="Users" resultType="Users">
select * from employee order by id
</select> <!-- 分页查询表所有属性 -->
<select id="selectPageAll" parameterType="Ele" resultType="Users">
select t1.* from (select rownum as recnum, t2.* from(select * from
employee
<where>
<if test="usName!=null">
And name=#{usName}
</if>
<if test="usAge!=null">
And age=#{usAge}
</if>
<if test="usEmail!=null">
And email=#{usEmail}
</if>
</where>
order by id) t2 )t1 where t1.recnum>=#{pageStart} and
t1.recnum<=#{pageEnd} </select>
<!-- 分页查询表所有属性 -->
<select id="selectAllBy" parameterType="Ele" resultType="Users">
select t1.* from (select rownum as recnum, t2.* from(select * from
employee
<where>
<if test="usName!=null">
And name like '%'||#{usName}||'%'
</if>
<if test="usAge!=null">
And age=#{usAge}
</if>
<if test="usEmail!=null">
And email=#{usEmail}
</if>
</where>
order by id) t2 )t1 where t1.recnum>=#{pageStart} and
t1.recnum<=#{pageEnd} </select>
<!-- 选择查询单一对象属性 -->
<select id="selectUser" parameterType="int" resultMap="user">
select
*
from employee where id = #{id}
</select>
<!-- 主键自增插入oracle -->
<insert id="insertUsers" parameterType="Users">
insert into
employee
values(#{id},#{name},#{age},#{email})
</insert>
<!-- 修改单一对象属性 -->
<update id="updateUsers" parameterType="Users">
update employee set
name =
#{name},
age = #{age},
email = #{email}
where id = #{id}
</update>
<!-- 删除单一对象 -->
<delete id="deleteUsers" parameterType="Users">
delete from
employee where id = #{id}
</delete>
</mapper>
查出来的所有列名在
com.ceno.smile.domain.Ad这个类中都有相应的属性对应,且该属性含有set方法
return adList;
} public void setAdList(PaginatedList adList) {
this.adList = adList;
}
package com.ceno.smile.presentation;import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ceno.smile.domain.Ad;
import com.ceno.smile.service.AdService;
import com.ibatis.common.util.PaginatedList;@SuppressWarnings("serial")
public class AdBean extends AbstractBean {
/**
*
*/
private int id;
private Ad ad;
private AdService adService;
private PaginatedList adList;
private PageBean pageBean;
private String pageDriection;
private String gotoPage;
private int pageJump;
private List<Integer> pageJumpList; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public Ad getAd() {
return ad;
} public void setAd(Ad ad) {
this.ad = ad;
} public AdService getAdService() {
return adService;
} public void setAdService(AdService adService) {
this.adService = adService;
} public PaginatedList getAdList() {
return adList;
} public void setAdList(PaginatedList adList) {
this.adList = adList;
} public PageBean getPageBean() {
return pageBean;
} public void setPageBean(PageBean pageBean) {
this.pageBean = pageBean;
} public String getPageDriection() {
return pageDriection;
} public void setPageDriection(String pageDriection) {
this.pageDriection = pageDriection;
} public String getGotoPage() {
return gotoPage;
} public void setGotoPage(String gotoPage) {
this.gotoPage = gotoPage;
} public int getPageJump() {
return pageJump;
} public void setPageJump(int pageJump) {
this.pageJump = pageJump;
} public List<Integer> getPageJumpList() {
return pageJumpList;
} public void setPageJumpList(List<Integer> pageJumpList) {
this.pageJumpList = pageJumpList;
} public AdBean() {
this(new AdService());
} public AdBean(AdService adService) {
this.adService = adService;
ad = new Ad();
pageBean = new PageBean();
pageJumpList = new ArrayList<Integer>(); } /**
* 获取ad列表
*
* @return
*/
public String getListAd() {
List<Ad> adList = adService.getListAd(ad);
if (null != adList) {
setMessageOfSession("adList", adList);
}
return SUCCESS;
} /**
* 分页
*
* @return
*/
public String getAdListForPage() {
try {
adList = adService.getAdListForPage();
System.out.println(adList);
pageBean.setPageSize(adList.getPageSize());
pageBean.setNowPage(adList.getPageIndex() + 1);
pageBean.setTotalRecored(adService.getAdCount());
setMessageOfSession("adList", adList);
setMessageOfSession("pageBean", pageBean);
pageJumpList();
} catch (Exception e) {
e.printStackTrace();
System.out.println(adList);
}
return SUCCESS;
} /**
* 遍历总页数
*/
private void pageJumpList() {
pageJumpList = new ArrayList<Integer>();
for (int i = 1; i <= pageBean.getTotalPage(); i++) {
pageJumpList.add(i);
}
} /**
* 上页下页
*
* @return
*/
public String pnPage() {
pageJumpList();
if ("next".equals(pageDriection)) {
adList.nextPage();
pageBean.setNowPage(adList.getPageIndex() + 1);
pageJump = adList.getPageIndex() + 1;
} else if ("previous".equals(pageDriection)) {
adList.previousPage();
pageBean.setNowPage(adList.getPageIndex() + 1);
pageJump = adList.getPageIndex() + 1;
}
return SUCCESS;
} /**
* 跳转
*
* @return
*/
public String newsListPageJump() {
pageJumpList();
int toPage = Integer.valueOf(pageJump) - 1;
pageBean.setNowPage(pageJump);
adList.gotoPage(toPage);
return SUCCESS;
} /**
* 增加广告
*
* @return
*/
public String adInsert() {
ad.setAddTime(new Date());
if (adService.insertAd(ad) > 0) {
setMessage("Back", "../../getAdListForPage.shtml");
clear();
return SUCCESS;
}
System.out.println("失败");
return FAILURE; } /**
* 删除广告
*
* @return
*/
public String adDelete() {
if (adService.deleteAdById(id) == 1) {
return SUCCESS;
}
return FAILURE;
} /**
* 更新广告
*
* @return
*/
public String adUpdate() {
if (adService.updateAd(ad) == 1) {
return SUCCESS;
}
return FAILURE;
} public void clear() {
ad = new Ad();
}
}
service
package com.ceno.smile.service;import java.util.List;import com.ceno.smile.domain.Ad;
import com.ceno.smile.persistence.DaoConfig;
import com.ceno.smile.persistence.iface.AdDAO;
import com.ibatis.common.util.PaginatedList;
import com.ibatis.dao.client.DaoManager;public class AdService {
private AdDAO adDAO; public AdService() {
DaoManager daoManager = DaoConfig.getDaomanager();
adDAO = (AdDAO) daoManager.getDao(AdDAO.class);
} public int getAdCount() {
return adDAO.getAdCount();
} public PaginatedList getAdListForPage() {
return adDAO.getAdListForPage();
} public List<Ad> getListAd(Ad ad) {
return adDAO.getListAd(ad);
} public int insertAd(Ad ad) {
return adDAO.insertAd(ad);
} public int deleteAdById(int id) {
return adDAO.deleteAdById(id);
} public int updateAd(Ad ad) {
return adDAO.updateAd(ad);
}
}
* 获取ad列表
*
* @return
*/
public String getListAd() {
List<Ad> adList = adService.getListAd(ad);
if (null != adList) {
setMessageOfSession("adList", adList);
}
return SUCCESS;
}他没报你个重名的错误?你PaginatedList并不是cllection中的集合 你用iterator怎么可能遍历
package com.ceno.smile.domain;import java.io.Serializable;
import java.util.Date;public class Ad implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int id;// 广告id
private String types;// 广告类型
private String adPosition;// 广告位置
private String adTitle;// 广告标题
private String adContent;// 广告内容
private String adpage;// 广告投放页面
private String isSys;// 是否系统广告 Y/N
private int orders;// 排序
private String image1;// 广告图片1
private String image2;// 广告图片2
private String src;// 其它资源
private String addMan;// 添加人id
private Date addTime;// 添加时间
public Ad() {
super();
}
/*
* constructor
*/
public Ad(int id, String types, String adPosition, String adTitle,
String adContent, String adpage, String isSys, int orders,
String image1, String image2, String src, String addMan,
Date addTime) {
super();
this.id = id;
this.types = types;
this.adPosition = adPosition;
this.adTitle = adTitle;
this.adContent = adContent;
this.adpage = adpage;
this.isSys = isSys;
this.orders = orders;
this.image1 = image1;
this.image2 = image2;
this.src = src;
this.addMan = addMan;
this.addTime = addTime;
} public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getTypes() {
return types;
} public void setTypes(String types) {
this.types = types;
} public String getAdPosition() {
return adPosition;
} public void setAdPosition(String adPosition) {
this.adPosition = adPosition;
} public String getAdTitle() {
return adTitle;
} public void setAdTitle(String adTitle) {
this.adTitle = adTitle;
} public String getAdContent() {
return adContent;
} public void setAdContent(String adContent) {
this.adContent = adContent;
} public String getAdpage() {
return adpage;
} public void setAdpage(String adpage) {
this.adpage = adpage;
} public String getIsSys() {
return isSys;
} public void setIsSys(String isSys) {
this.isSys = isSys;
} public int getOrders() {
return orders;
} public void setOrders(int orders) {
this.orders = orders;
} public String getImage1() {
return image1;
} public void setImage1(String image1) {
this.image1 = image1;
} public String getImage2() {
return image2;
} public void setImage2(String image2) {
this.image2 = image2;
} public String getSrc() {
return src;
} public void setSrc(String src) {
this.src = src;
} public String getAddMan() {
return addMan;
} public void setAddMan(String addMan) {
this.addMan = addMan;
} public Date getAddTime() {
return addTime;
} public void setAddTime(Date addTime) {
this.addTime = addTime;
}}
id 广告 types 广告类型('echo', 'js', 'iframe', 'text', 'code', 'image', 'flash') adPosition 广告位置 adTitle 广告标题 adContent 广告内容 adpage 广告投放页面 isSys 是否系统广告(本网站广告) Y:是 N:否 orders 排序 image1 广告图片 image2 广告图片 src 其他资源,如:flash等 addMan 添加人ID addTime 添加时间
select id as id,types as types,adposition as adPosition,adtitle as adTitle,adcontent as adContent,adpage as adpage,issys as isSys,orders as orders,image1 as image1,image2 as image2,src as src,addman as addMan,addtime as addTime from ad
我认为IBATIS不会那么智能,他能够分辨出以下属性的大小写。。比如adpage,adContent