Spring 3とTiles 2を備えたAjax Rest Call to Webアプリ
-
30-10-2019 - |
質問
Spring 3とTiles 2を使用して構築されたWebAppがあります(安らかではありません)。 urlbasedViewResolverを使用してビューを表示しています
私のApplication-Servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<context:component-scan base-package="com.xxx.xxxx.xxxxx.web.controller" />
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
</beans>
私のtiles.xml
<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/views/layout.jsp">
<put-attribute name="header" value="/WEB-INF/views/header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/views/footer.jsp" />
</definition>
<definition name="welcome" extends="base.definition">
<put-attribute name="body" value="/WEB-INF/views/welcome.jsp" />
</definition>
</tiles-definition>
私の問題は、1つのドロップダウンボックスからオプションが選択されている場合、フライ(JavaScriptを使用)に基づいてフライ(JavaScriptを使用)で生成されるクライアント側にダイナミックフォームを持っていることです。最初のドロップダウンメニューでは、これらのオプションが定数であるため、問題はありません。しかし、2回目のドロップダウンメニューの選択のために、具体的でサーバーでのみ利用可能な情報を読み込む必要があるので、Ajaxコール(REST FUL)を作成することを考えたので、このようなコントローラーを作成しました
私の安らかなコントローラー:
@Controller
public class UtilsController {
private WebAdministration admin;
public UtilsController() throws WebAdministrationException {
this.admin = WebAdministration.getInstance();
}
@RequestMapping(value="/aaaa/${site}/${type}", method=RequestMethod.GET, headers="Accept=text/xml, application/json")
public @ResponseBody List<String> getRemoteSites(@PathVariable("site") String site, @PathVariable("type") String type) {
List<String> remoteSites = null;
Config config = (Config) admin.getImplemantationData().get(Implementations.IMPL);
if (type.equals(Config.PERSISTENCE)) {
remoteSites = config.getRemoteSites().get(site).getNewRemoteSites();
}
else if (type.equals(Config.OLD)) {
remoteSites = config.getRemoteSites().get(site).getOldRemoteSites();
}
return remoteSites;
}
}
私のajaxコール:
<script type="text/javascript">
function getRemoteSites(site, type) {
$.getJSON('/aaaa/'+site+'/'+type, {
ajax : 'true'
}, function(data) {
var len = data.length;
for ( var i = 0; i < len; i++) {
document.write('<form:checkbox path="remoteSites" value="' + valueArray[i] + '" />');
}
});
};
</script>
そして、私のajaxリクエストは404で失敗します - マッピングは見つかりませんでした。
REST URLを機能させるにはどうすればよいですか。新しいビューリゾルバーが必要であることは知っていますが、過去2日間、非常に多くのことを試み、正しい解決策を探しました。
何か助けがありますか?
ありがとうございました
正しい解決策はありません
所属していません StackOverflow