分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

SSH 框架controller向jsp传递List jsp中使用el表达式获取

发布时间:2023-09-06 02:23责任编辑:苏小强关键词:jsjsp

mvc可以使用ModelAndViev传递数据选择跳转的视图

controller中的代码, 把一个模拟的表单studentListSimulate传给ModelAndView

 ???@RequestMapping("/detial") ???public Model showStudentDetial(Model mod) { ???????ModelAndView mav = new ModelAndView(); ???????mav.addObject("studentListSimulate", studentListSimulate); ???????mav.setViewName("jsp/student_detial"); ???????return mod; ???}

jsp中可以使用el表达式获取model中studentListSimulate的元素,然后再通过实体类的属性,获取属性的值

这是model实体类中的属性

public class StudentModel { ???private int studentIdInModel; ???private String studentNameInModel; ???private int studentAgeInModel;

如图

如果,是从数据库里查询到一个list怎么办呢? 如何从controller中向jsp传递呢?

同样是 把list传给ModelAndView ,只不过这次的list变了,是在dao中生成,返回给service然后再返回给controller的

验证一下,已经传入了

前台,使用el表达式获取model中的list项目即可

SSH 框架controller向jsp传递List jsp中使用el表达式获取

原文地址:https://www.cnblogs.com/jnhs/p/10005931.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved