当前位置: 首页 > news >正文

javaee springMVC model的使用

项目结构图

在这里插入图片描述

pom依赖

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>TestSpringMVC3</artifactId><version>1.0-SNAPSHOT</version><packaging>war</packaging><name>TestSpringMVC3 Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.7</maven.compiler.source><maven.compiler.target>1.7</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.3.18.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>4.3.18.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>4.3.18.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>4.3.18.RELEASE</version></dependency><!-- 导入SpringMvc 需要的jar包 --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.3.18.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>4.3.18.RELEASE</version></dependency><!-- 配置servlet--><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope></dependency><!-- jstl --><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><!-- 1.2以下的版本 需要加standard架包 --><!--<dependency><groupId>taglibs</groupId><artifactId>standard</artifactId><version>1.1.2</version></dependency>--></dependencies><build><finalName>TestSpringMVC3</finalName><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>3.2.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin></plugins></pluginManagement></build>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"id="WebApp_ID" version="3.0"><display-name>Archetype Created Web Application</display-name><!-- 加入前端控制器 DispatcherServlet --><servlet><servlet-name>dispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- 设置 DispatcherServlet 的参数 --><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:springmvc.xml</param-value></init-param><!-- 1 启动服务器的时候就加载  --><!-- 0 使用的时候再加载 --><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>dispatcherServlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping></web-app>

spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!-- 1. 配置  需要扫描的控制层在哪个包  --><context:component-scan base-package="com.test"></context:component-scan><!-- 2 配置 视图解析器 中的 前缀和后缀  --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><!-- 设置前缀  --><property name="prefix" value="/WEB-INF/"/><!-- 设置后缀 --><property name="suffix" value=".jsp"/></bean><!-- 开启注解驱动注册了两个数据转换的注解@NumberFormatannotation支持,@DateTimeFormatjson相关的。。--><mvc:annotation-driven></mvc:annotation-driven></beans>

controller

package com.test.controller;import com.test.pojo.Address;
import com.test.pojo.Users;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;@Controller
@RequestMapping("/users")public class UsersController {@RequestMapping("/getUser")public String getUser(Model model){Users user=new Users(1,"daimenglaoshi","888",new Address(1,"shanghai"),new Date(),888888);model.addAttribute("user",user);return "showUser";}}

jsp

<%--Created by IntelliJ IDEA.User: HIAPADDate: 2019/12/4Time: 14:08To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Title</title>
</head>
<body>
${user.uname}
</body>
</html>

相关文章:

javaee springMVC model的使用

项目结构图 pom依赖 <?xml version"1.0" encoding"UTF-8"?><project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org…...

Spring与Docker:如何容器化你的Spring应用

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页——&#x1f405;&#x1f43e;猫头虎的博客&#x1f390; &#x1f433; 《面试题大全专栏》 &#x1f995; 文章图文…...

试图替代 Python 的下一代AI编程语言:Mojo

文章目录 为什么叫 Mojo &#xff1f;Python 家族的一员&#xff0c;MojoPython 的好处&#xff1a;Python 兼容性Python 的问题移动和服务器部署&#xff1a;Python 子集和其他类似 Python 的语言&#xff1a; Mojo 是一种创新的编程语言&#xff0c;结合了 Python 的可用性和…...

【数据结构】栈、队列和数组

栈、队列和数组 栈队列数组数组的顺序表示和实现顺序表中查找和修改数组元素 矩阵的压缩存储特殊矩阵稀疏矩阵 栈 初始化 #define MaxSize 50//栈中元素的最大个数 typedef char ElemType;//数据结构 typedef struct{int top;//栈顶指针ElemType data[MaxSize];//存放栈中的元…...

python算法调用方案

1、python算法部署方案 &#xff08;1&#xff09;独立部署 算法端和应用端各自独立部署。 使用WSGI&#xff08;flask&#xff09;web应用A包装算法&#xff0c;并发布该应用A。 应用端B 通过httpclient调用算法应用A中的api接口。 &#xff08;2&#xff09;统一部署 算法…...

《微服务架构设计模式》第二章

文章目录 微服务架构是什么软件架构是什么软件架构的定义软件架构的41视图模型为什么架构如此重要 什么是架构风格分层式架构风格六边形架构风格微服务架构风格什么是服务什么是松耦合共享类库的角色 为应用程序定义微服务架构识别操作系统根据业务能力进行拆分业务能力定义了一…...

taro vue3 ts nut-ui 项目

# 使用 npm 安装 CLI $ npm install -g tarojs/cli 查看 Taro 全部版本信息​ 可以使用 npm info 查看 Taro 版本信息&#xff0c;在这里你可以看到当前最新版本 npm info tarojs/cli 项目初始化​ 使用命令创建模板项目&#xff1a; taro init 项目名 taro init myApp …...

【群答疑】jmeter关联获取上一个请求返回的字符串,分割后保存到数组,把数组元素依次作为下一个请求的入参...

一个非常不错的问题&#xff0c;来检验下自己jmeter基本功 可能有同学没看懂题&#xff0c;这里再解释一下&#xff0c;上面问题需求是&#xff1a;jmeter关联获取上一个请求返回的字符串&#xff0c;分割后保存到数组&#xff0c;把数组元素依次作为下一个请求的入参 建议先自…...

Shell 函数详解(函数定义、函数调用)

Shell 函数的本质是一段可以重复使用的脚本代码&#xff0c;这段代码被提前编写好了&#xff0c;放在了指定的位置&#xff0c;使用时直接调取即可。 Shell 中的函数和C、Java、Python、C# 等其它编程语言中的函数类似&#xff0c;只是在语法细节有所差别。 Shell 函数定义的语…...

git-命令行显示当前目录分支

1. 打开家目录.bashrc隐藏文件&#xff0c;找到如下内容 forlinxubuntu:~$ vi ~/.bashrcif [ "$color_prompt" yes ]; thenPS1${debian_chroot:($debian_chroot)}\[\033[01;32m\]\u\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ elsePS1${debian_chroot:($debi…...

pgsql 报错 later table “drop column” is not supported now

报错 使用pgsql执行下面的SQL报错 alter table test_user drop clolumn name;报错信息&#xff1a; later table “drop column” is not supported now。 报错原因 hologres pgsql的数据库&#xff1a; 删除列目前还是灰度测试阶段&#xff0c;需要在sql前加上set hg_ex…...

如何制定私域流量布局计划?

01 确定目标用户群体 首先&#xff0c;明确目标用户是私域流量布局的基础。可以通过市场调研、用户画像和数据分析等方式&#xff0c;了解目标用户的年龄、性别、兴趣爱好等特征&#xff0c;为后续精准营销奠定基础。 02 选择合适的私域流量渠道 根据目标用户群体的特点&…...

yolov8 模型部署--TensorRT部署-c++服务化部署

写目录 yolov8 模型部署--TensorRT部署1、模型导出为onnx格式2、模型onnx格式转engine 部署 yolov8 模型部署–TensorRT部署 1、模型导出为onnx格式 如果要用TensorRT部署YOLOv8&#xff0c;需要先使用下面的命令将模型导出为onnx格式&#xff1a; yolo export modelyolov8n.p…...

自适应迭代扩展卡尔曼滤波算法AIEKF估计SOC VS 扩展卡尔曼估计SOC

自适应迭代扩展卡尔曼滤波算法&#xff08;AIEK&#xff09; 自适应迭代扩展卡尔曼滤波算法&#xff08;AIEK&#xff09;是一种滤波算法&#xff0c;其目的是通过迭代过程来逐渐适应不同的状态和环境&#xff0c;从而优化滤波效果。 该算法的基本思路是在每一步迭代过程中&a…...

2023-亲测有效-git clone失败怎么办?用代理?加git?

git 克隆不下来&#xff0c;超时 用以下格式&#xff1a; git clone https://ghproxy.com/https://github.com/Tencent/ncnn.git 你的网站前面加上 https://ghproxy.com/ 刷的一下就下完了&#xff01;&#xff01;...

An Empirical Study of GPT-3 for Few-Shot Knowledge-Based VQA

本文是LLM系列文章&#xff0c;针对《An Empirical Study of GPT-3 for Few-Shot Knowledge-Based VQA》的翻译。 GPT-3对基于小样本知识的VQA的实证研究 摘要引言相关工作方法OK-VQA上的实验VQAv2上的实验结论 摘要 基于知识的视觉问答&#xff08;VQA&#xff09;涉及回答需…...

2023高教社杯数学建模B题思路分析 - 多波束测线问题

# 1 赛题 B 题 多波束测线问题 单波束测深是利用声波在水中的传播特性来测量水体深度的技术。声波在均匀介质中作匀 速直线传播&#xff0c; 在不同界面上产生反射&#xff0c; 利用这一原理&#xff0c;从测量船换能器垂直向海底发射声波信 号&#xff0c;并记录从声波发射到…...

02-docker network

Docker网络 Docker网络是什么 Docker 网络是 Docker 容器之间进行通信和连接的网络环境。在 Docker 中&#xff0c;每个容器都有自己的网络命名空间&#xff0c;这意味着每个容器都有自己的网络接口、IP 地址和网络配置 Docker网络启动后&#xff0c;会在宿主机中建立一个名…...

栈和队列经典笔试题

文章目录 栈和队列的回顾&#x1f4bb;栈&#x1fa73;队列&#x1f45f; 栈和队列经典笔试题&#x1f50b;有效的括号&#x1f3b8;用队列实现栈 &#x1f56f;用栈实现队列&#x1f52d;设计循环队列&#x1f9fc; 安静的夜晚 你在想谁吗 栈和队列的回顾&#x1f4bb; 栈&am…...

No5.9:多边形内角和公式

#!/usr/bin/python # -*- coding: UTF-8 -*-#指定了编码&#xff0c;中文就能正常展示 # codingutf-8def calc_degree(n):#n代表边形的总数degree (n - 2) * 180#多边形内角和公式return degreeprint(calc_degree(3))#三角形的内角和 print(calc_degree(4))#四边形的内角和【小…...

告别内存焦虑:用DiskANN在单机上搞定十亿向量检索的完整配置与调优指南

告别内存焦虑&#xff1a;用DiskANN在单机上搞定十亿向量检索的完整配置与调优指南 当你的推荐系统需要处理超过1亿条商品特征向量&#xff0c;或是生物医药团队要匹配数十亿分子结构时&#xff0c;传统内存索引方案会让服务器内存条价格直接突破年度预算。这时DiskANN就像一位…...

【NR 定位】3GPP NR Positioning 5G定位标准解读(七):RRC_INACTIVE状态下的高效定位机制

1. RRC_INACTIVE状态下的5G定位挑战与机遇 在5G网络中&#xff0c;RRC_INACTIVE状态是一种独特的节能模式&#xff0c;它允许设备在保持部分网络连接的同时大幅降低功耗。这种状态特别适合物联网设备&#xff0c;比如智能电表、资产追踪器和可穿戴设备。想象一下你家的智能门锁…...

brpc配置中心高可用部署:集群配置与故障转移全攻略

brpc配置中心高可用部署&#xff1a;集群配置与故障转移全攻略 【免费下载链接】brpc brpc is an Industrial-grade RPC framework using C Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendat…...

LabelMe企业级部署方案:多用户权限管理与审计

LabelMe企业级部署方案&#xff1a;多用户权限管理与审计 LabelMe是一款强大的图像标注工具&#xff0c;支持多边形、矩形、圆形等多种标注形式&#xff0c;广泛应用于计算机视觉领域的数据准备工作。在企业环境中部署LabelMe时&#xff0c;多用户权限管理与操作审计是确保数据…...

NocoDB终极指南:零代码构建企业级可视化数据库平台

NocoDB终极指南&#xff1a;零代码构建企业级可视化数据库平台 【免费下载链接】nocodb nocodb/nocodb: 是一个基于 node.js 和 SQLite 数据库的开源 NoSQL 数据库&#xff0c;它提供了可视化的 Web 界面用于管理和操作数据库。适合用于构建简单的 NoSQL 数据库&#xff0c;特别…...

当分包时,主包里有未被引用的文件,小程序预览【代码质量】显示包体积过大,不影响发布

1.项目加入分包后预览时显示主包体积超出&#xff1f;排查分包没问题&#xff0c;外部库方法也不会占很多空间2.代码依赖分析【显示 - 主包体积正常】主包实际体积&#xff08;768KB&#xff09;明明远小于 2MB 上限&#xff0c;但工具却提示「主包尺寸应小于 1.5M」且未通过。…...

3分钟掌握Windows音频路由:让每个程序都有专属音频输出 [特殊字符]

3分钟掌握Windows音频路由&#xff1a;让每个程序都有专属音频输出 &#x1f3a7; 【免费下载链接】audio-router Routes audio from programs to different audio devices. 项目地址: https://gitcode.com/gh_mirrors/au/audio-router 你是否曾经遇到过这样的烦恼&…...

DLL与静态库怎么选?5个真实案例解析动态链接库的优劣

DLL与静态库的架构决策&#xff1a;5个实战场景下的技术选型指南 1. 模块化开发中的DLL实践 在大型软件系统中&#xff0c;模块化设计是降低复杂度的关键策略。我们曾为某金融交易系统设计插件架构时&#xff0c;DLL的动态加载特性展现出独特优势&#xff1a; 内存共享机制&…...

LeRobot框架深度解析:3个核心模块实现机器人学习的PyTorch统一解决方案

LeRobot框架深度解析&#xff1a;3个核心模块实现机器人学习的PyTorch统一解决方案 【免费下载链接】lerobot &#x1f917; LeRobot: State-of-the-art Machine Learning for Real-World Robotics in Pytorch 项目地址: https://gitcode.com/GitHub_Trending/le/lerobot …...

超实用的三角高程观测记录及平差计算表格程序

三角高程观测记录及平差计算表格程序:通过给出的高程点的坐标&#xff08;边长&#xff09;和高程&#xff0c;只要填写点号&#xff0c;就能实现自动反向计算测量过程&#xff0c;并自动生成四个测回的观测记录。 非常实用方便&#xff0c;表格界面简洁&#xff0c;通用&#…...