idea创建springmvc项目

目录

1.创建一个maven工程

2,pom.xml导入依赖 

3.src/main 创建一个webapp的目录,然后配置web.xml

4.配置web.xml

5.resource下配置springMVC.xml

springMVC.xml内容

冷知识 smart server的配置,或者直接自己部署一个tomcat就行

写一个controller类测试访问


1.创建一个maven工程

File->new project,选择maven 

一路next

2,pom.xml导入依赖 



    
    
        org.springframework
        spring-webmvc
        5.3.1
    

    
    
        ch.qos.logback
        logback-classic
        1.2.3
    

    
    
        javax.servlet
        javax.servlet-api
        3.1.0
        provided
    

    
    
        org.thymeleaf
        thymeleaf-spring5
        3.0.12.RELEASE
    

3.src/main 创建一个webapp的目录,然后配置web.xml

project structure里面

idea创建springmvc项目_第1张图片

idea创建springmvc项目_第2张图片

 最后是这个样子

idea创建springmvc项目_第3张图片

4.配置web.xml















    
    
        springMVC
        org.springframework.web.servlet.DispatcherServlet
        
        
            
            contextConfigLocation
            
            classpath:springMVC.xml
        
        
        1
    
    
        springMVC
        
        /
    

5.resource下配置springMVC.xml

idea创建springmvc项目_第4张图片

引入了名称空间,没引入的使用 alt+enter

idea创建springmvc项目_第5张图片

springMVC.xml内容





    
    
    

    
    
        
        
        
            
                
                    

                        
                        

                        
                        
                        
                        
                    
                
            
        
    

    
    

    
    
        
            
            
                
                
                    
                        text/html
                        application/json
                    
                
            
        
    

冷知识 smart server的配置,或者直接自己部署一个tomcat就行

需要在idea插件里面下载一个插件

idea创建springmvc项目_第6张图片

 配置

idea创建springmvc项目_第7张图片

写一个controller类测试访问

idea创建springmvc项目_第8张图片

 

访问idea创建springmvc项目_第9张图片


idea创建springmvc项目_第10张图片 

若当前请求的请求地址满足请求映射的value属性,但是请求方式不满足method属性,则浏览器报错405:Request method 'POST' not supported  

 

 

 

你可能感兴趣的:(springmvc,intellij-idea,java,maven,spring,servlet)