spring mvc 实现获取后端传递的值操作示例
作者:倾听岁月 时间:2023-08-10 12:55:52
本文实例讲述了spring mvc 实现获取后端传递的值。分享给大家供大家参考,具体如下:
jsp页面怎么获取从后端传递过来的值?
JSTL 方法获取后端传递的值
@RequestMapping("index1")
public ModelAndView index1()
{
ModelAndView model = new ModelAndView("/Index/index");
model.addObject("msg","my name is 勇哥");
List<String> list = new ArrayList<String>();
list.add("1");
list.add("2");
list.add("3");
list.add("4");
model.addObject("list",list);
return model;
}
后端传递对象msg 和 对象list,并将对象存储在request作用域中。
<%@ page
language="java"
pageEncoding="utf-8"
contentType="text/html;charset=utf-8"
isELIgnored="false"
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page
import="java.util.*"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test </title>
</head>
<body>
<!--JSTL 方式获取后台传递的变量-->
<p>${msg}</p>
<!--从request作用域中获取-->
<%
List<String> list = (List<String>)request.getAttribute("list");
for(String str : list)
{
%>
<p>循环数 : <%=str%></p>
<%
}
%>
</body>
</html>
希望本文所述对大家java程序设计有所帮助。
来源:https://blog.csdn.net/u014559227/article/details/78020234
标签:spring,mvc,后端传递的值
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android应用开发SharedPreferences存储数据的使用方法
2023-06-23 16:02:47
![](https://img.aspxhome.com/file/2023/0/82410_0s.jpg)
Android数据存储方式操作模式解析
2023-07-27 02:47:05
idea创建SpringBoot项目时Type选maven project和maven pom有何区别
2023-07-04 07:20:27
![](https://img.aspxhome.com/file/2023/9/57499_0s.png)
JFinal实现伪静态的方法
2023-07-17 12:11:37
![](https://img.aspxhome.com/file/2023/0/57630_0s.jpg)
flutter轮子计划之进度条
2023-06-21 07:59:39
完美解决Android Studio集成crashlytics后无法编译的问题
2023-06-23 16:49:07
![](https://img.aspxhome.com/file/2023/8/82388_0s.jpg)
tomcat部署java web项目遇到的问题及解决方法
2023-08-04 23:44:27
![](https://img.aspxhome.com/file/2023/2/58032_0s.jpg)
springboot post接口接受json时,转换为对象时,属性都为null的解决
2023-06-17 15:24:23
![](https://img.aspxhome.com/file/2023/3/57313_0s.png)
IDEA集成MyBatis Generator插件的使用
2023-08-12 00:28:47
![](https://img.aspxhome.com/file/2023/6/57896_0s.png)
IOS与网页JS交互详解及实例
2023-07-08 11:58:20
Intellij搭建springmvc常见问题解决方案
2023-07-23 12:53:29
![](https://img.aspxhome.com/file/2023/9/57419_0s.png)
Android利用传感器实现微信摇一摇功能
2023-07-12 05:05:18
java8到java15的新功能简介
2023-07-28 02:18:18
android压力测试命令monkey详解
2023-06-17 00:36:29
重温C# clr 笔记总结
2023-06-22 02:24:30
Android四大组件之broadcast广播使用讲解
2023-07-27 12:41:50
![](https://img.aspxhome.com/file/2023/8/86008_0s.png)
SpringBoot整合Mybatis实现多数据源配置与跨数据源事务实例
2023-06-29 23:47:34
Spring @Conditional通过条件控制bean注册过程
2023-08-06 10:00:11
Android使用Rotate3dAnimation实现3D旋转动画效果的实例代码
2023-07-30 12:21:29
![](https://img.aspxhome.com/file/2023/9/85449_0s.png)
C语言头文件<string.h>函数详解
2023-07-01 18:59:34
![](https://img.aspxhome.com/file/2023/2/105162_0s.png)