spring-mvc.xml

1.spring-mvc.xml

  1. pom.xml

        
            org.springframework
            spring-webmvc
            ${spring.version}
        


        
            org.springframework
            spring-jdbc
            ${spring.version}
        


        
            org.springframework
            spring-test
            ${spring.version}
            test
        


 
        
            commons-fileupload
            commons-fileupload
            1.3.3
        

 2.spring-mvc.xml




    
    

    
    
        
            
        
    

    
    
        
            
                text/html;charset=UTF-8
                application/json;charset=UTF-8
            
        
        
            
                
                    
                        AllowArbitraryCommas
                        AllowUnQuotedFieldNames
                        DisableCircularReferenceDetect
                    
                
                
            

        
    

    
    
        
        
    

    
    
    
    

    
    
        
        
    

    
    
        
            
            
            
            
            
            
            
                 
        
    

3.LoginInterCeptor.java

package net.wanho.interceptor;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import java.util.Arrays;

public class LogInteceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
//        System.out.println("preHandle=======");
        String path = request.getServletPath();
//        System.out.println(path);
        if(Arrays.asList("/login.jsp","/login").contains(path)){
            return true;
        }

        if(request.getSession().getAttribute("currentUser")!=null) {
           return true;
       }

       response.sendRedirect("login.jsp");
       return false;
    }

}

 

4.web.xml




  Archetype Created Web Application

  
  
    contextConfigLocation
    classpath:spring.xml,classpath:spring-mybatis.xml
  
  
    org.springframework.web.context.ContextLoaderListener
  
    
     
  
    mf
    org.springframework.web.filter.HiddenHttpMethodFilter
  
  
    mf
    /*
  

  
  
    springmvc
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath:spring-mvc.xml
    
    1
  
  
    springmvc
    /
  



 

你可能感兴趣的:(xml)