SSM---访问后台提示HTTP Status 404 - /**/**

今天在编写Spring Security 自定义页面登入提示:

HTTP Status 404 - /SpringSecurity/login.action




spring_mvc.xml 配置文件:
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:mvc="http://www.springframework.org/schema/mvc"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans    
  7.                         http://www.springframework.org/schema/beans/spring-beans-3.1.xsd    
  8.                         http://www.springframework.org/schema/context    
  9.                         http://www.springframework.org/schema/context/spring-context-3.1.xsd    
  10.                         http://www.springframework.org/schema/mvc    
  11.                         http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">  
  12.                           
  13.      
  14.        
  15.     <context:component-scan base-package="com.common.controller" />  
  16.       
  17.     <!--避免IE执行AJAX时,返回JSON出现下载文件 -->  
  18.     <bean id="mappingJacksonHttpMessageConverter"  
  19.         class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">  
  20.         <property name="supportedMediaTypes">  
  21.             <list>  
  22.                 <value>text/html;charset=UTF-8</value>  
  23.             </list>  
  24.         </property>  
  25.     </bean>  
  26.     <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->  
  27.     <bean  
  28.         class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
  29.         <property name="messageConverters">  
  30.             <list>  
  31.                 <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 -->  
  32.             </list>  
  33.         </property>  
  34.     </bean>  
  35.       
  36.       
  37.     <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->  
  38.     <bean id="multipartResolver"    
  39.         class="org.springframework.web.multipart.commons.CommonsMultipartResolver">    
  40.         <!-- 默认编码 -->  
  41.         <property name="defaultEncoding" value="utf-8" />    
  42.         <!-- 文件大小最大值 -->  
  43.         <property name="maxUploadSize" value="10485760000" />    
  44.         <!-- 内存中的最大值 -->  
  45.         <property name="maxInMemorySize" value="40960" />    
  46.     </bean>   
  47.     
  48.       
  49.      
  50.   
  51.   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
  52.         <property name="prefix" value="/WEB-INF/pages/"></property>  
  53.         <property name="suffix" value=".jsp"></property>  
  54.     </bean>  
  55.   
  56.   
  57.   
  58. </beans>  
<?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等等),才导致页面总是提示:无法访问相关的资源信息
      

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值