package cn.demo.controller;
import cn.demo.pojo.Items;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by silivar on 2018/10/27.
*/
//如果不加注解,只是一个普通的javabean,tomcat启动时不会扫描它
@Controller
public class ItemsController {
/*指定url到请求方法的映射,即url中输入一个地址,找到这个方法。
例如:localhost:8080/springmvc/list.action
*/
@RequestMapping("/list")
public ModelAndView itemsList() throws Exception {
// 集合
List<Items> itemList = new ArrayList<>();
//商品列表
Items items_1 = new Items();
items_1.setName("联想笔记本_3");
items_1.setPrice(6000f);
items_1.setDetail("ThinkPad T430 联想笔记本电脑!");
Items items_2 = new Items();
items_2.setName("苹果手机");
items_2.setPrice(5000f);
items_2.setDetail("iphone6苹果手机!");
itemList.add(items_1);
itemList.add(items_2);
/*模型和视图
*model模型:模型对象中存放了返回给页面的数据
* view视图:视图对象中指定了返回的页面的位置
* */
ModelAndView modelAndView=new ModelAndView();
//将返回给页面的数据放入模型和视图对象中
modelAndView.addObject("itemList",itemList);
//指定返回的页面位置
modelAndView.setViewName("/WEB-INF/jsp/itemList.jsp");
return modelAndView;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springmvc.zip (54个子文件)
springmvc
src
cn
demo
pojo
Items.java 1KB
controller
ItemsController.java 2KB
springmvc.iml 2KB
.idea
artifacts
springmvc_war_exploded.xml 511B
libraries
lib.xml 290B
kotlinc.xml 232B
misc.xml 2KB
compiler.xml 170B
workspace.xml 62KB
inspectionProfiles
Project_Default.xml 1KB
modules.xml 258B
web
WEB-INF
jsp
itemList.jsp 1KB
classes
cn
demo
pojo
Items.class 2KB
controller
ItemsController.class 2KB
springmvc.xml 894B
lib
spring-aop-4.1.3.RELEASE.jar 351KB
jstl-1.2.jar 405KB
spring-beans-4.1.3.RELEASE.jar 691KB
spring-jms-4.1.3.RELEASE.jar 263KB
commons-logging-1.1.1.jar 59KB
spring-web-4.1.3.RELEASE.jar 697KB
spring-webmvc-4.1.3.RELEASE.jar 763KB
spring-expression-4.1.3.RELEASE.jar 253KB
spring-messaging-4.1.3.RELEASE.jar 281KB
spring-core-4.1.3.RELEASE.jar 983KB
spring-jdbc-4.1.3.RELEASE.jar 417KB
spring-tx-4.1.3.RELEASE.jar 246KB
spring-context-4.1.3.RELEASE.jar 1003KB
spring-aspects-4.1.3.RELEASE.jar 55KB
spring-context-support-4.1.3.RELEASE.jar 174KB
web.xml 1KB
index.jsp 310B
config
springmvc.xml 894B
out
artifacts
springmvc_war_exploded
WEB-INF
jsp
itemList.jsp 1KB
classes
cn
demo
pojo
Items.class 2KB
controller
ItemsController.class 2KB
springmvc.xml 894B
lib
spring-aop-4.1.3.RELEASE.jar 351KB
jstl-1.2.jar 405KB
spring-beans-4.1.3.RELEASE.jar 691KB
spring-jms-4.1.3.RELEASE.jar 263KB
commons-logging-1.1.1.jar 59KB
spring-web-4.1.3.RELEASE.jar 697KB
spring-webmvc-4.1.3.RELEASE.jar 763KB
spring-expression-4.1.3.RELEASE.jar 253KB
spring-messaging-4.1.3.RELEASE.jar 281KB
spring-core-4.1.3.RELEASE.jar 983KB
spring-jdbc-4.1.3.RELEASE.jar 417KB
spring-tx-4.1.3.RELEASE.jar 246KB
spring-context-4.1.3.RELEASE.jar 1003KB
spring-aspects-4.1.3.RELEASE.jar 55KB
spring-context-support-4.1.3.RELEASE.jar 174KB
web.xml 1KB
index.jsp 310B
共 54 条
- 1
资源评论
卡夫卡的熊kfk
- 粉丝: 3590
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- libjpeg 编译所需的 Win32.mak vs编译libjpeg
- 自动驾驶-状态估计和定位-粒子滤波实现和源码.pdf
- 数据可视化-智慧物流服务中心大屏页面.zip
- yolov5,SSD 可能使用到的一些代码
- bbbbbbbbbbbbbbbbbb
- 安卓逆向学习笔记之Frida Stalker 还原OLLVM AES.docx
- 安卓逆向学习笔记之unicorn来trace还原OLLVM Base64.docx
- 基于jquery的自定义表格组件实现
- Nessus最新20240426离线安装插件all-2.0.tar.gz
- 最新版本私钥助记词碰撞器大富豪使用python进行制作通过接口的方式进行验证支持多币种多链多网络一分钟万次验证高出货率
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功