[精讚] [會員登入]
633

[vue.js] 設定 content type

今天在wickt 端怎麼就是收不到vue.js 以post 傳過來的資料 找了好久才發現 application/jso

分享此文連結 //n.sfs.tw/10306

分享連結 [vue.js] 設定 content type @igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
2016-11-26 23:21:47 最後編修
2016-11-26 23:13:52 By igogo
 

今天在wickt 端遇到怎麼就是收不到vue.js 以post 傳過來的資料

找了好久才發現 application/json 與 application/x-www-form-urlencoded 的不同

前端必須用 application/x-www-form-urlencoded 送, wicket 才收得到

Vue.http.options.emulateJSON = true;

 

ContentType 為 application/json

Vue.http.options.emulateJSON = false;

 

 

在wicket端回傳json 格式時 也要設定ContentType

   getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() {
            @Override
            public void respond(IRequestCycle requestCycle
            ) {
                //回傳json 格式
                ((WebResponse) requestCycle.getResponse()).setContentType("application/json");
                // Add JSON-encoded string to the response.
                Response response = requestCycle.getResponse();
                response.write(returnValue);
            }

 

END

你可能感興趣的文章

java-身份証字號驗証 FormatCheck.java public class FormatCheck { private volatile

spring boot jpa 使用多個欄位排序 我有一entity 叫 team 資料欄下如下 @Id @GeneratedValue(strategy = Gener

Thread java thread

使用poi 解析 docx 原先是想解析出在docx 中的文字跟圖片, 但是, 有些我們認為是圖片, 其實是用方程式表示, 實在是太麻煩了 就記錄一

ArrayList 想移除特定值 想移出water, 使用lambda 的方式如下 List<String> fruits = new Arr

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

vue.js components 多個組件的呈現 vue.js 組件 component

編碼的順序 utf8 big5

hoc2018灑水機器人 灑水機器人的工作是替行道樹灑水,機器人的灑水範圍有限(左前方、左方、左後方),請寫程式控制機器 人判斷須灑水的狀況。每顆

臺中市校務雲端系統與Windows AD帳號整合(1) active directory,ldaps,雲端校務系統

刪除資料夾內的檔案 lambda 一行文 Arrays.stream(new File("/folder/path").