ちょっと、次の問題が発生しました。jspx ファイルの内容は次のとおりです。
function postSMTH() {
$.ajax({
type: "POST",
url: document.getElementById("urltxt").value,
data: parameters,
});
}
<input type="hidden" value="${pageContext.request.contextPath}/foo/foo2/foodat" name="urltxt" id="urltxt"/>
<div class="foodat"><a href="javascript:postSMTH();"><spring:message code="foo_foo2_foodat_text" text="FOODAT"/></a></div>
したがって、送信ボタンを押すと、postSMTH
関数が呼び出され、ajax オブジェクトが次のようにコントローラーに貼り付けられます。
@Controller
@RequestMapping(value="/foo")
public class FooController {
..............
@RequestMapping(value="/foo2", method=RequestMethod.POST)
public String homePOST(HttpServletRequest request) {
........
}
@RequestMapping(value="/foo2", method=RequestMethod.GET)
public String homeGET(HttpServletRequest request) {
........
}
@RequestMapping(value="/foo2/foodat", method=RequestMethod.POST)
public String doTHAT(HttpServletRequest request) {
// check authorization
Map fooMap = request.getParameterMap();
// do something in the Database, depending on the paramMap
return "redirect:/foo/foo1";
}
}
データベースに関してはすべて正常に機能していますが、問題は、最後のリダイレクトが機能しないことです。ページ foo2 にとどまります。
私はSpringが初めてです。おそらくどこかで少し間違いがあります。私は自分でそれを理解することはできません。
どなたかヒントになれば幸いです。ありがとう