ここで、不足しているコンポーネントを最後に追加しています....以下のコードに問題がある場合は修正してください: コンテキスト xml ファイル:
<mvc:resources location="/custom1/" mapping="/js/**" />
<mvc:annotation-driven />
<context:component-scan base-package="com.vk" />
<context:annotation-config />
<bean id="JspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
以下のJavaScriptコード:
$.ajax({url: "/JSONExample/post/account",
type: "POST",
data: {userName: "Sam" },
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(result) {
alert(result);
}
});