InternalResourceViewResolverを使用して通常のビューをレンダリングできたSpringプロジェクトがあります。現在、タイルを使用してUIをモジュール化しようとしています。ブラウザでhttp:// localhost:8080 / myapp / tradeaggregationを指定すると、次のようになります。
URI [/ myapp/tradeaggregation]を使用したHTTPリクエストのマッピングが見つかりません。
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
サーブレット-コンテキスト.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean name="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass"
value="org.springframework.web.servlet.view.tiles2.TilesView" />
</beans:bean>
<beans:bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/views/tiles.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean>
<context:component-scan base-package="com.ks.kdweb.controllers" />
</beans:beans>
tiles.xml
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="tradeaggregation" template="/WEB-INF/views/index.jsp">
<put-attribute name="content" value="/WEB-INF/views/tradeAggregation.jsp"/>
</definition>
</tiles-definitions>
そして私のコントローラー:
@Controller
public class TradeAggregatorController {
private static final String TITLE = "Trade Aggregation";
private static final String[] columns = new String[] { "listvalues", "numtrades", "sizesum" };
@Autowired
private JdbcAggConfigDefDao aggConfigDefDao;
@RequestMapping("/tradeaggregation")
public String load(@RequestParam("configdefid") long configDefId, @RequestParam("aggid") String aggId, Model model) {
List<AggConfigDef> configs = this.aggConfigDefDao.getAggConfigDefsByType(TradeAggregation.class.getName());
model.addAttribute("aggConfigs", configs);
model.addAttribute("title", TITLE);
model.addAttribute("tradeAggs", this.aggConfigDefDao.getTradeAggregations(configDefId, aggId));
model.addAttribute("columns", columns);
return "tradeaggregation";
}
public void setAggConfigDefDao(JdbcAggConfigDefDao aggConfigDefDao) {
this.aggConfigDefDao = aggConfigDefDao;
}
}