web 后臺返回json格式數據的方式(status 406)

1.在類上使用注解?

@RestController
public class HttpComentInterface {}

2.在方法是使用注解??@ResponseBody

   @RequestMapping(path = "/interface/queryRemote", method = RequestMethod.POST) //可以指定請求方式@ResponseBody public RemoteCommentResultData queryCommentPage(@RequestBody QueryCommentParamDTO queryCommentParamDTO, HttpServletRequest request) {
}

3.使用 out

  @RequestMapping(value ="/GetSomeInfos" ,produces = "application/json;charset=UTF-8")public ModelAndView getNearestAirport(HttpServletRequest request, HttpServletResponse response)throws Exception {logger.info("NearestAirportController.getNearestAirport begin");RemoteAirportsData data = nearestAirportService.getNearestAirports();response.setContentType("text/html;charset=UTF-8");response.setCharacterEncoding("UTF-8");String result = JSONObject.fromObject(data).toString();response.getWriter().print(result);logger.info("NearestAirportController.getNearestAirport end");return null;}

4.如果出現了 status 406 則是項目中缺少? jackson-core-asl-1.9.12.jar,jackson-mapper-asl-1.9.12.jar 這兩個包

引起的原因:
由于設置了@ResponseBody,要把對象轉換成json格式,缺少轉換依賴的jar包,故此錯。

?

也可以用response返回結果,就不用手動去加這兩個jar包了

轉載于:https://www.cnblogs.com/UncleWang001/p/10790618.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/279598.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/279598.shtml
英文地址,請注明出處:http://en.pswp.cn/news/279598.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

OpenStack Juno系列之計算節點搭建

OpenStack Juno系列之計算節點搭建 nova-compute安裝配置 -------------------- apt-get install nova-compute sysfsutils 編輯配置文件 vi /etc/nova/nova.conf [DEFAULT] verbose True rpc_backend rabbit rabbit_host controller rabbit_password RABBIT_PASS auth_str…

quantum_如何從Firefox Quantum刪除Pocket

quantumFirefox Quantum has deep integration with the Pocket read-it-later service, which is now owned by Mozilla. You’ll see a Pocket page action in the address bar, a “View Pocket List” feature in the Library, and recommended articles from Pocket on th…

vue-typescript

教你搭建typescript的vue項目 自尤大神去年9月推出vue對typescript的支持后,一直想開箱嘗試vuets,最近一個新項目準備入手typescript,也遇到了很多坑,下面就一步步來吧!!! 1. 項目創建和初始化 …

Couchbase概述

Couchbase概述 Couchbase概述 Couchbase概述Couchbase最早叫Membase,是由Memcached項目組的一些頭目另立的山頭。2011年與CouchDB合并,正式命名為Couchbase。2013年,作為NoSQL技術初創企業,拿到了2500萬美元的D輪投資。截稿時止&a…

Windows 2012 - Dynamic Access Control 淺析

Windows 2012相對于前幾個版本而已,做出了大量的改進,尤其體現在安全性和虛擬化方面。Dynamic Access Control ( 動態訪問控制)是微軟在文件服務器的訪問控制上的新功能,極大的提高了安全性和靈活性。經過一天的研究學習&#xff…

windows rt_如何在Windows RT上輕松將網站添加到Flash白名單

windows rtMicrosoft’s Surface RT and other Windows RT-based machines include the Flash browser plugin, but it only runs on websites Microsoft has whitelisted. We have covered how you can add any website to the Flash whitelist, but now there’s an easier w…

powershell實現設置程序相關性腳本

公司一直有臺服務器cpu占用很高,分析出是恒生監控程序java占用很高,且三個java程序,僅其中一個很高,要恒生解決,一直未解決,導致每周重啟,我司運維都要手動進行程序相關性設置,給運維…

解決npm 的 shasum check failed for錯誤

使用npm安裝一些包失敗,類似如下報錯情況: C:\Program Files\nodejs>npm update npm npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\np…

chromebook刷機_您可以購買的最好的Chromebook,2017年版

chromebook刷機While once considered a novelty item by many tech enthusiasts, Chromebooks have broken out of the “just a browser” mold and become legitimate laptops. They’re full-featured, lightweight machines that can do everything most users need them …

Jmeter JDBC請求-----數據庫讀取數據進行參數化 通過SSH跳板機連接數據庫

前期準備: jdbc驅動:mysql-connector-java-5.1.7-bin.jar Jmeter 要鏈接MySQL數據庫,首選需要下載mysql jdbc驅動包(注:驅動包的版本一定要與你數據庫的版本匹配,驅動版本低于mysql版本有可能會導致連接失敗…

Exchange server 2010 beta安裝部署流程

本文使用了微軟公開發布的exchange server 2010 beta進行部署測試。這篇文檔將用到下列產品 windows server 2008 64bit enterprise AD function at windows server 2008 exchange server 2010 beta ----------該exchange server 2010 beta版本屬于早期版本,目前最新…

08.15《CEP職業發展規劃課》

在12,13號的放假后,14,15號安排了CEP職業發展規劃課,為期兩天的課,內容也是很豐富。 在14號的早上,學習了職場中的基本禮儀、和基本素養的培訓,同時對未來的職業規劃做出了大致的分析。 在14號的下午開始了簡歷寫作的課…

usb 驅動修復_您可以修復物理損壞的USB驅動器嗎?

usb 驅動修復Sometimes accidents happen to a USB drive, and you find yourself in a very bad position when your only copy of an important document is on there. When something like this happens, is it possible to fix a physically broken USB drive? Today’s S…

大白話5分鐘帶你走進人工智能-第二十節邏輯回歸和Softmax多分類問題(5)

大白話5分鐘帶你走進人工智能-第二十節邏輯回歸和Softmax多分類問題(5) 上一節中,我們講解了邏輯回歸的優化,本節的話我們講解邏輯回歸做多分類問題以及傳統的多分類問題,我們用什么手段解決。 先看一個場景,假如我們現在的數據集…

Exchange 2016部署實施案例篇-01.架構設計篇(上)

年前就答應大家要給大家寫一個關于Exchange規劃部署的文章,一直忙到現在也沒有倒出時間來寫這個東西。特別是節后,更是開工不利啊,各種奇葩問題,真心無語了。廢話就不多說了,開始今天的議題。 相信各位對Microsoft Exc…

bzoj 4598: [Sdoi2016]模式字符串

題目描述 給出n個結點的樹結構T&#xff0c;其中每一個結點上有一個字符&#xff0c;這里我們所說的字符只考慮大寫字母A到Z&#xff0c;再給出長度為m的模式串s&#xff0c;其中每一位仍然是A到z的大寫字母。 Alice希望知道&#xff0c;有多少對結點<u&#xff0c;v>滿足…

[譯] 機器學習可以建模簡單的數學函數嗎?

原文地址&#xff1a;Can Machine Learning model simple Math functions?原文作者&#xff1a;Harsh Sahu譯文出自&#xff1a;掘金翻譯計劃本文永久鏈接&#xff1a;github.com/xitu/gold-m…譯者&#xff1a;Minghao23校對者&#xff1a;lsvih&#xff0c;zoomdong機器學習…

下載spotify音樂_如何在Spotify上播放更高質量的音樂

下載spotify音樂With Spotify Premium, you get access to higher quality music streaming. By default (and if you’re on the free plan), Spotify streams at 96kbps on mobile and 160kbps on your computer. At these sort of bitrates, you’ll hear a small but notic…

ubuntu scp命令或者用root連接ssh提示:Permission denied, please try again.錯誤

1、su -            #&#xff01;&#xff01;&#xff01; 2、vi /etc/ssh/sshd_config 3、PermitRootLogin yes    # 找到此字段&#xff0c;改為此行所示 4、/etc/init.d/ssh restart    # 重啟ssh服務 轉載于:https://www.cnblogs.com/weiyiming007/p…

Windows下壓縮包安裝Mysql

1. 下載mysql壓縮包 2. 解壓到指定目錄&#xff0c;例如D:\Program Files\mysql-5.7.25-winx64 3. 在目錄下創建配置文件my.ini [mysqld] port 3306 basedirD:/Program Files/mysql-5.7.25-winx64 datadirD:/Program Files/mysql-5.7.25-winx64/data max_connections200 char…