Spring MVC 提示:HTTP Status 404/**/**

符号 阅读:628 2021-03-31 22:11:14 评论:0
今天在编写Spring Security 自定义页面登入提示:

HTTP Status 404 - /SpringSecurity/login.action




spring_mvc.xml 配置文件:
<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
	xmlns:context="http://www.springframework.org/schema/context" 
	xmlns:mvc="http://www.springframework.org/schema/mvc" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans   
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd   
                        http://www.springframework.org/schema/context   
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd   
                        http://www.springframework.org/schema/mvc   
                        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 
                         
    
      
    <context:component-scan base-package="com.common.controller" /> 
	 
	<!--避免IE执行AJAX时,返回JSON出现下载文件 --> 
	<bean id="mappingJacksonHttpMessageConverter" 
		class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> 
		<property name="supportedMediaTypes"> 
			<list> 
				<value>text/html;charset=UTF-8</value> 
			</list> 
		</property> 
	</bean> 
	<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> 
	<bean 
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
		<property name="messageConverters"> 
			<list> 
				<ref bean="mappingJacksonHttpMessageConverter" />	<!-- JSON转换器 --> 
			</list> 
		</property> 
	</bean> 
	 
	 
	<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> 
	<bean id="multipartResolver"   
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">   
        <!-- 默认编码 --> 
        <property name="defaultEncoding" value="utf-8" />   
        <!-- 文件大小最大值 --> 
        <property name="maxUploadSize" value="10485760000" />   
        <!-- 内存中的最大值 --> 
        <property name="maxInMemorySize" value="40960" />   
    </bean>  
   
     
    
 
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
        <property name="prefix" value="/WEB-INF/pages/"></property> 
        <property name="suffix" value=".jsp"></property> 
    </bean> 
 
 
 
</beans>

 在该spring_mvc.xml 配置文件中主要完成的任务如下:
1、添加Controller 的自动扫描功能
2、返回View 视图资源封装
3、FileUpload 文件上传
4、AJAX 异步请求 实体注解

重点缺少:
<mvc:annotation-driven />   注解驱动注入(比如:Controller、@RequestMapping等等),才导致页面总是提示:无法访问相关的资源信息
      

标签:Spring
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号