qq_18085437 2021-01-05 18:12 采纳率: 50%
浏览 75

ssm框架-controller层的model数据传不到jsp

springmvc.xml 

<!-- 配置扫描器 -->
		<context:component-scan base-package="cn.edu.xit.controller"></context:component-scan>


		<!-- 配置视图解释器ViewResolver -->
		<bean id="viewResolver"
			class="org.springframework.web.servlet.view.InternalResourceViewResolver">
			<property name="prefix" value="/jsp/"></property>
			<property name="suffix" value=".jsp"></property>
		</bean>

		<!-- 注解驱动:配置处理器映射器和适配器 -->
		<mvc:annotation-driven />

 main.jsp

	<c:if test="${customers!=null }">

						<table border=1>
								<tr>
									<td>订单号</td>
									<td>订单价格</td>
									<td>订单状态</td>
									
								</tr>
									<c:forEach items="${customers}" var="row">
										<tr>
										<td>${row.o_id }</td>
										<td>${row.price}</td>
										<td>${row.o_state}</td>
										
										</tr>
									</c:forEach>
							</table>
			
			</c:if>

 controller层

@Controller
public class CustomerController {
	@Autowired
	private  CustomerService customerService;
	
	
	
	@RequestMapping("findCustomer")
	public String findCustomer(Model model){
		List<Customer> customers= customerService.findCustomer();
		
		
			System.out.println("-------------------"+model);
	   
		model.addAttribute("customers",customers);

		return "main";
	}
	}

mapper.xml

<select id="findCustomer" resultType="cn.edu.xit.po.Customer" parameterType="Integer">
select o_id,price,o_state from oder
</select>

 上面是文件的一些代码,从数据库表得到的数组没有返回到main.jsp。

 

失败输出结果截图:

使用<c:if>:

 不使用<c:if> :

所以从controller层的customers是空的?

求解!!!!!可以私信下谢谢!! 

  • 写回答

5条回答 默认 最新

  • Mr.Qubb 2021-01-05 19:22
    关注

    你要看看你从数据库查出来,有没有数据;没有数据那肯定就 没办法展示了啊

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)