springmvc 初步

1,新建maven工程

springmvc 初步_第1张图片

springmvc 初步_第2张图片springmvc 初步_第3张图片


maven update

如没有 在下新建 java目录和test/java 目录  然后maven update

springmvc 初步_第4张图片

如果 index.jsp 出现 javax.servlet.http.HttpServlet 错误

springmvc 初步_第5张图片


2,打开pom.xml 输入spring mvc 和jedis需要的jar包

(1) 修改之前可以更换下载的镜像地址,以增加下载速度,此处用的是阿里的镜像

打开F:\apache-maven-3.3.9\conf\settings.xml; 


springmvc 初步_第6张图片

   
      alimaven
      aliyun maven
    http://maven.aliyun.com/nexus/content/groups/public/
      central        
   


(2)pom.xml 添加


	4.0.0
	com.shaw.demo
	jedis-demo
	war
	0.0.1-SNAPSHOT
	jedis-demo Maven Webapp
	http://maven.apache.org

	
		4.2.4.RELEASE
		2.8.1
		1.7.7
		1.2.17
		5.1.34
		3.2.8
		4.0.2.GA
		1.0.0.GA
		2.6
	
	
		
			junit
			junit
			3.8.1
			test
		

		
		
			redis.clients
			jedis
			${jedis.version}
		
		
		
			org.springframework
			spring-core
			${spring.version}
		

		
			org.springframework
			spring-web
			${spring.version}
		
		
			org.springframework
			spring-oxm
			${spring.version}
		
		
			org.springframework
			spring-tx
			${spring.version}
		

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

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

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

		
			org.springframework
			spring-context-support
			${spring.version}
		

		
			org.springframework
			spring-test
			${spring.version}
		
		
		
			org.mybatis
			mybatis
			${mybatis.version}
		
		
		
			org.mybatis
			mybatis-spring
			1.2.2
		
		
		
			mysql
			mysql-connector-java
			5.1.30
		
		
		
			commons-dbcp
			commons-dbcp
			1.2.2
		
		
		
			jstl
			jstl
			1.2
		
		
		
		
			log4j
			log4j
			${log4j.version}
		


		
		
			com.alibaba
			fastjson
			1.1.41
		
		
			org.slf4j
			slf4j-api
			${slf4j.version}
		
		
			org.slf4j
			slf4j-log4j12
			${slf4j.version}
		
			
			
				org.codehaus.jackson
				jackson-mapper-asl
				1.9.13
			
			
			
				commons-fileupload
				commons-fileupload
				1.3.1
			
			
				commons-io
				commons-io
				2.4
			
			
				commons-codec
				commons-codec
				1.9
			

			
			
				commons-lang
				commons-lang
				${apache.commons.version}
			

		
			javax.validation
			validation-api
			${validationapi.version}
		
		
			org.hibernate
			hibernate-validator
			${validationhibernate.version}
		

	
	
		jedis-demo
	


里面有些许的冗余暂就不做删除了。

(2),修改web.xml





    web项目
    
   	
        contextConfigLocation
        classpath:/spring/spring-context.xml
    
    
        org.springframework.web.context.ContextLoaderListener
    
    
		org.springframework.web.context.request.RequestContextListener
	
    
    
    
    
    
        spring mvc servlet
        DispatcherServlet
        org.springframework.web.servlet.DispatcherServlet
        
            spring mvc 配置文件
            contextConfigLocation
            classpath:spring/spring-mvc.xml
        
        1
    

    
        DispatcherServlet
        *.do
    
    
    
    
    
    
        encodingFilter
        
            org.springframework.web.filter.CharacterEncodingFilter
        
        
            encoding
            UTF-8
        
        
            forceEncoding
            true
        
    
    
        encodingFilter
        *
    
	 
    
		404
		/error/404.html
	
	
		index.jsp
	


(3) 新建spring-mvc



	
	
	
     	
	
	
	
       
           
               
           
       
   
    
   
	     
          
	      
		  
          
          
          
    
	
	

	
	
	  
        
          
        
          
        
          
     



(4),新建spring-context


  
	
	
	
	
	
	
	
	

	


(5) 新建controller


此处即可访问http://localhost:8080/jedis-demo/index/toIndex.do



你可能感兴趣的:(spring,mvc,maven)