[精讚] [會員登入]
941

[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

你可能感興趣的文章

停止多執行緒 利用主程式呼叫多執行緒時, 要怎麼停止正在執行的多執行緒

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

Arrays.asList 後想再add出現 UnsupportedOperationException 這個問題真是搞死我了 List<String> fruits = Arrays.asList("a

ArrayList 與 HashMap 範例 public static void main(String[] args) { String titleIds = &

java lambda files filter java, files filter, lambda

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

隨機好文

[scratch2] 分數排名 在清單中隨机產生5名學生的考試分數, 再利用另一個清單排名 想法, 分數愈高者排名愈好, 例如名次是第5名, 那分數是最

[scratch] 將角色物件放到清單中,並依序讀出每個角色的X值 將角色物件放到清單中,並依序讀出每個角色的X值

使用vbs設定windows 10 靜態IP setting static ip Set Adapter = GetObject("winmgmts:Win

管理Google共用雲端硬碟 管理Google共用雲端硬碟

spring boot 整合到 nginx 於subpath 將spring boot 位在docker中, 對外服務19090 程式佈署到nginx 伺服器的 subpath上 對