SSM中零散小问题总结

这篇博客总结了SSM框架(Spring、SpringMVC、MyBatis)使用过程中遇到的一些具体问题,包括ModelAndView的重定向操作、启动报错、MyBatis的参数错误、多表操作策略、resultType与resultMap的使用误区以及MyBatis插入返回主键ID的方法。还探讨了MyBatis中集合默认值和SSM配置拦截器的设置。
摘要由CSDN通过智能技术生成

本篇文章不会系统的讲解知识也不会深入讲,只会说明一个很具体的问题,属于随手记录型。

如何用 ModelAndView 进行重定向


//返回一个ModelAndView
public ModelAndView updateInfo(Info info) {
   

		ModelAndView modelAndView = new ModelAndView();
		
		//更新
		infoService.updateSelect(info);
		

		// 设置视图,到更新成功页面
		modelAndView.setViewName("redirect:/xxxx/Update.jsp");
    
		return modelAndView;

}

//或者 参数里来一个
public ModelAndView updateInfo(ModelAndView modelAndView) {
   
    
    // 设置视图,到更新成功页面
	modelAndView.setViewName("redirect:/xxxx/Update.jsp");
    
}

只是一种(其他还有很多)

SSM工程启动报错:foreach的集合,不是var而是item

Ignoring bean creation exception on FactoryBean type check: 
	org.springframework.beans.factory.UnsatisfiedDependencyException: 

		Error creating bean with name 'certificateArticleMapper' defined in file [xxx...\dao\CertificateArticleMapper.class]:

			 Unsatisfied dependency expressed through bean property 'sqlSessionFactory': :
			 	 Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-datasource.xml]:

			 	 	 Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [xxx...m\oracle\entity\InfoMapper.xml]'; 

			 	 	 nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.

			 	 	   Cause: org.xml.sax.SAXParseException; lineNumber: 616; columnNumber: 74; 必须为元素类型 "foreach" 声明属性 "var"。; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\Program Files (x86)\apache-tomcat-8.5.38\wtpwebapps\o2o\WEB-INF\classes\com\oracle\entity\InfoMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 616; columnNumber: 74; 必须为元素类型 "foreach" 声明属性 "var"。

InfoMapper.xml 里面mybatis的 foreach 写错 了,,不是var ,是 item。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值