springmvc 支持对象与json 自动转换的配置
基于maven的工程,
需要在pom.xml中添加如下依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
在springmvc的配置文件中添加如下代码
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
<!--支持对象与json的自动转换-->
<mvc:annotation-driven />
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.3.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
"> <!--关于扫描包的问题https://blog.csdn.net/lhpnba/article/details/77988616-->
<context:component-scan
base-package="com.hs" >
<!--只扫描控制器。 -->
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!--支持对象与json的自动转换-->
<mvc:annotation-driven />
<!--对静态资源的处理-->
<mvc:resources mapping="/static/**" location="/static/" />
<!-- 视图解析器 -->
<!-- <bean class="org.springframework.web.servlet.HandlerInterceptor"></bean> -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".jsp"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
</bean>
</beans>
springmvc的配置用以支持json和对象的自动转换
springmvc 支持对象与json 自动转换的配置的更多相关文章
- ajax-json,遇到的一个问题,jquery var ,加载顺序。JS对象,json格式转换。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python 对象和json互相转换
一.python对json的支持 从python2.6开始,python标准库中添加了对json的支持,操作json时,只需要import json即可. 二.python对象转换成json字符串 在 ...
- GSON中Java对象与JSON互相转换——(一)
json的转换插件是通过java的一些工具,直接将java对象或集合转换成json字符串. 常用的json转换工具有如下几种: 1)jsonlib 2)Gson:google 3)fastjson:阿 ...
- Json:Java对象和Json文本转换工具类
Json 是一个用于 Java 对象 和 Json 文本 相互转换的工具类. 安装 下载源码 git clone https://github.com/njdi/durian.git 编译源码 cd ...
- Java对象与JSON互相转换jsonlib以及手动创建JSON对象与数组——(二)
首先声明一下,jsonlib转换与GSON相比太差劲了,操作不是一般的繁琐.GSON可以直接转换成各种集合与对象类型.强烈推荐使用GSON.而且GSON一个方法就可以解决,jsonlib转来转去太繁琐 ...
- js:JSON对象与JSON字符串转换
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式. 同时,JSON是 JavaScript 原生格式,这 ...
- java 字符串转json,json转实体对象、json字符串转换成List、List转String、以及List排序等等...
@RequestMapping(value = "updateInvestorApplyAccountNo", method = RequestMethod.POST) @Resp ...
- 对象与json字符串转换类设计
public static class JsonNewtonsoft { /// <summary> /// 把对象转换为JSON字符串 /// </summary> /// ...
- Java中对象和json互相转换的工具类
package com.Dingyu.util; import java.util.List; import com.fasterxml.jackson.core.JsonProcessingExce ...
随机推荐
- 廖雪峰Java12maven基础-2maven进阶-2模块管理
1. 把大项目拆分为模块是降低软件复杂度的有效方法 在Java项目中,我们通常会会把一个项目分拆为模块,这是为了降低软件复杂度. 例如:我们可以把一个大的项目氛围module-a, module-b, ...
- 廖雪峰Java11多线程编程-3高级concurrent包-9Fork_Join
线程池可以高效执行大量小任务: Fork/Join线程池可以执行一种特殊的任务: 把一个大任务拆成多个小任务并行执行 Fork/Join是在JDK 1.7引入的 示例:计算一个大数组的和 Fork/J ...
- 用C++Builder在Windows开始按钮上绘图制作方法
熟悉Windows操作系统的软件设计人员知道,在Win95/98/NT/2000中有一任务栏(Task Bar)程序,路径为:C:\WINDOWS\SYSTEM\SYSTRAY.EXE(假设你的Win ...
- 第八章 Odoo 12开发之业务逻辑 - 业务流程的支持
在前面的文章中,我们学习了模型层.如何创建应用数据结构以及如何使用 ORM API 来存储查看数据.本文中我们将利用前面所学的模型和记录集知识实现应用中常用的业务逻辑模式. 本文的主要内容有: 以文件 ...
- springboot与任务(定时任务)
描述: 项目开发中经常需要执行一些定时任务,比如需要在每天凌晨时候,分析一次前一天的日志信息.Spring为我们提供了异步执行任务调度的方式,提供TaskExecutor .TaskScheduler ...
- CSS3如何实现圆圈转圈,附demo
如图,如何实现圆圈转圈? 主要还是CSS3动画(只兼容了谷歌,需要兼容其它浏览器,加前缀即可) .move1 { animation: myMove1 5s ease-in infinite alte ...
- c语言学习笔记 - 指针和数组
结合内存存储数据的机制,c语言里指针的出现和使用也就不奇怪了,如果先学了内存的一些知识,以及程序运行机制,到了c指针这块就会清晰很多. #include <stdio.h> int mai ...
- mysql 主从,双主同步
1.创建用户并设置远程访问授权 1). A上添加: //ip地址为B的ip地址,用于B访问 ' with grant option; 2). B上添加://ip地址为A的ip地址,用于A访问 ' wi ...
- js获取网页屏高 屏宽
<SCRIPT LANGUAGE="JavaScript"> <!-- //document.body.scrollTop 滚动条的上端距离 //document ...
- gnome-tweak-tool设置gnome参数, 修改CENTOS7桌面图标大小
GNOME Tweak Tool 是 GNOME 3 的优化配置工具,为我们带来 GNOME Shell 扩展安装功能,方便Linux用户对 Gnome Shell 进行一些调整. 主要功能有:安装, ...