Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "categoryId")

进入商品列表页面先是报的这个错Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "categoryId"),我真是纳闷了,吃饭前一点问题没有,吃完就报错了。还好我吃饭前把代码上传到git.oschina了,于是我把本地删了,拉了个新的。没想到给自己挖了个大坑。。。

代码拉下来之后,启动tomcat,报错!tomcat无法启动,说是某某目录没删,于是我机(dou)智(bi)的手动删了。

再启动tomcat,报错!java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

先是百度到了这个

  1. spring-web 的jar包没导进去

  2. jar包邮冲突,把重复的jar包删除

  3. 在web.xml加上<context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext-*.xml</param-value>
        </context-param>

因为默认的读取的是/WEB-INF下的配置文件,如果配置文件在src中要把路径改为类路径底下

4.把工程刷新一下,因为工程是部署在服务器底下的,要把加入的jar包部署到工程里。

并没有解决问题!!

又百度到了这个

如果你是maven项目,tomcat在发布项目的时候没有同时发布maven依赖所添加的jar包,
你需要设置一下eclipse:
项目 —> 属性 -> Deployment Assembly -> Add -> Java Build Path Entries -> 选择Maven Dependencies -> Finish -> OK
把对应的Maven依赖包也发布到tomcat,调试时会自动把那些jar发布到指定目录下,tomcat也能找到那些jar了。

确实是maven项目不错,但还是没有解决。我感觉Maven Dependencies下的jar包都没有用上,然后我就那些jar包拷到lib下,然后add to build path,终于不报没找到类了!

然而,进入页面,又报错!The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

百度到了这个(原地址:http://blog.csdn.net/lzz313/article/details/7554736)

可能一

web项目出现如上问题,据查是版本问题:
JSTL 1.0 的声明是:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core " %>

JSTL1.1 的声明是:
 <%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core %>
项目中,已经是 jstl 1.2 版本了,页面中也全部是用<%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core %>这种方式。javaee5之后就只有 jstl.jar 这一个jar包了,没有standard.jar包,tld文件也打包到jar里面去了,啥在web.xml文件里配置jsp-config的解决方式也是浮云。

可能二

最终查到问题是 jstl.jar 包在ide项目中有,但在tomcat发布的应用WEB-INF/lib下没有,这是工具发布项目的问题,复制一个jar包过去问题就解决了。

>>jstl.jar没有

看了一下,忘了拷jstl-1.2.jar,复制粘贴add to  build path,OK!!!

     然而,万万没想到!进入商品列表页面又报了熟悉的错Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "categoryId"),妈蛋又转回来了!!!

  最终查明某行代码顺序写错了,至于为什么吃完饭前好好的,据大神说因为我之前操作没重启服务器balabala。。。下面贴出正确的

<!-- 分页  -->
	<select id="getGoodsByPage" resultMap="GoodsResultMap" parameterType="hashmap">
		select * from (select rownum rn,g.*,c.name cname from shop_goods g, shop_category c where g.categoryId=c.id
		<!-- 动态sql(商品查询) -->
		<if test="goods!=null">
		<if test="goods.categoryId!=null and goods.categoryId!=''">
			and g.categoryId=#{goods.categoryId}
		</if>
		<if test="goods.name!=null and goods.name!=''">
		  <!-- 模糊查询 -->
		  <bind name="goods.name" value="'%'+goods.name+'%'"/>
			and g.name like #{goods.name}
		</if>
		</if>
		) r
		where r.rn between (#{page}-1)*#{pageSize}+1 and #{page}*#{pageSize}
	</select>			<!--注意不是resultMap  -->
	<select id="getGoodsNum" resultType="int" parameterType="Goods">
		select count(*) from shop_goods g, shop_category c where g.categoryId=c.id
		<!-- 动态sql(商品查询) -->
		<if test="categoryId!=null and categoryId!=''">
			and g.categoryId=#{categoryId}
		</if>
		<if test="name!=null and name!=''">
		  <!-- 模糊查询 -->
		  <bind name="name" value="'%'+name+'%'"/>
			and g.name like #{name}
		</if>
	</select>


你可能感兴趣的:(Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "categoryId"))