我认为这可能与我配置的这一部分有关:
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
我在这里遵循了Spring Security Tutorial:http://docs.spring.io/spring-security/site/docs/3.2.x/guides/form.html。我无法导航到myApp / login,并且它没有显示在所有其他映射完成的日志中。
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String package.controller.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/officeSearchResults],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView package.controller.OfficeController.search(java.lang.String)
...
我的代码和示例之间的唯一区别是我在.jsp中构建了我的视图,而不是百里香。这是jsp,但我不确定它是否重要:
<form name="f" action="j_spring_security_check"
method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='j_username' value=''>
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="j_password" />
</td>
</tr>
</table>
<input name="submit" type="submit"
value="submit" />
<input name="reset" type="reset" />
</form>
更新:
的web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:jpaContext.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>
请提供建议或解决方案。感谢。