Ich versuche AJAX asynchron mit dem Server zu kommunizieren. Allerdings bin ich die folgende Fehlermeldung erhalten, Jede Idee ?:org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Anforderungsmethode 'GET' nicht unterstützt
org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Antrag Methode 'GET' nicht unterstützt
Controller:
package com.math.mvc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class PiCalculatorController {
@RequestMapping(value = "/picalculator", method = RequestMethod.GET)
public @ResponseBody String piCalculator(@RequestParam(value = "precision") int pr, @RequestParam(value = "decimals") int de) {
return String.valueOf(pr * de);
}
}
Javascript:
var getPiCalculation;
$(document).ready(function() {
getPiCalculation = function() {
if ($('#precision').val() != '' || $('#decimals').val() != '') {
$.getJSON(
"picalculator",
{
precision: $('#precision').val(),
decimals: $('#decimals').val()
},
function (data) {
alert("response received: " + data);
}
);
} else {
alert("Both fields need to be populated!!");
}
};
Headers: