2015-08-28 23 views
0

我期待Web調用的BigDecimal.toString()值。如何讓ajax在Spring MVC中調用文本到Java控制器?

,但我不設法對其進行配置和獲取爲404,未找到或406

以下是Spring MVC的代碼

@RequestMapping(value="get/myData", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) 
@ResponseBody 
public String getMyData(@ModelAttribute("user") User user, 
     @ModelAttribute("detailForm") DetailForm form) 
{ 
    //A web service called return big decimal and return that big decimal value toString 
    return "Value"; 
} 

以下是調用代碼:

var convId = $("#" + $("body form:first").attr("id")).find('input[name="_CONV_ID"]').val(); 



blockUI: false, 
      dataType: 'text', 
      type: 'GET', 
      url: "get/myData.do", 
      data: { '_CONV_ID': convId}, 
      success: function (data) { 
       // new dialog 
       alert(data); 
      }, 
      error: function (result) { 
       alert("Error" + result); 
      } 

任何人都可以幫助我調整代碼。在按鈕點擊時,值從BigDecimal類型的網絡服務返回

+0

您的ajax請求中的網址對我來說似乎不真實。試試:'get/myData.do' - >'get/myData' – Deh

+0

不是這個問題 – fatherazrael

+0

你是否同時提交表單? – Deh

回答

0

嘗試到達網址http://localhost:8080/your_application_name/get/myData。如果你發現404錯誤,你需要檢查你的web.xml。檢查servlet映射部分的部分。

相關問題