我正在開發基本的Spring項目並嘗試實現自定義登錄頁面。但是當我嘗試訪問HTML頁面時,它給了我錯誤「找不到頁面」,但是我的jsp頁面可以從同一位置訪問(即ProjectName/webcontent/Sample.jsp)。爲什麼我無法訪問html頁面?無法訪問HTML頁面但可訪問JSP頁面
的web.xml是: -
<!-- Spring Security -->
<filter>
<filter-name>filterChainProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>filterChainProxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>Sample1.html</welcome-file>
</welcome-file-list>
的security.xml
<security:http auto-config='true' use-expressions="true" authentication-manager- ref="FormBasedAuthenticationManager" >
<security:intercept-url pattern="/**" access="isAuthenticated()" />
</security:http>
<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
<security:filter-chain-map path-type="ant">
<security:filter-chain pattern="/**" filters="springSecurityFilterChain" />
</security:filter-chain-map>
</bean>
</beans>
sevlet.xml
<context:component-scan base-package="XYZ" />
<Secured:global-method-security secured-annotations="enabled" pre-post-annotations="enabled" jsr250-annotations="enabled"/>
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".html"/>
</bean>
您可以發佈您的視圖解析器代碼,看看你是如何配置? – Aeseir
@Aeseir我已經更新了 – user3640507
,所以你的html文件位於/ WEB-INF /文件夾中,沒有其他子文件夾? – Aeseir