は私がAngularJS
でデータをフェッチするためにRestController
を使用しますが、まだ私はindex.html
をロードするために定期コントローラを必要としなさい:春4で最初のビューコントローラを取り除くとAngularJS
@Controller
public final class LayoutController {
@RequestMapping(value = "/")
public String getIndexPage() {
return "/resources/index";
}
}
他のすべてのコントローラがRestController
秒です。インデックスファイルがjsp
の拡張子の場合は、LayoutController
を検索しませんが、html
の場合は必要です。 これは私のdispatcher
configです:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="1"></property>
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.html</value>
</property>
</bean>
</beans>
そして、これはapplicationContext
の一部です:
<mvc:annotation-driven/>
<tx:annotation-driven />
<mvc:resources mapping="/resources/**" location="WEB-INF/resources/" />
私はindex.html
の代わりindex.jsp
を使用したいときLayoutController
を取り除くために方法はありますか?事前にお手伝いいただきありがとうございます。 LayoutController
と全くInternalResourceViewResolver
なし
<mvc:view-controller path="/" view-name="/resources/index.html"/>
:受け入れ答えに基づいて ソリューション。
ありがとう:)私は、HTMLファイルを直接指し示すLayoutControllerとInternalResourceViewResolverの必要性を取り除きましたが、私にとっては最終的な解決策はあなたと少し違って見えます: ' ' - Intellijは"シンボルを解決できません/resources/index.html ""と表示しますが、それは動作します。 –