What are the conventional locations for for JSPs, JavaScript, CSS, Images in Maven web projects?

前端 未结 2 1625
我寻月下人不归
我寻月下人不归 2020-12-15 22:47

I need to convert a traditional J2EE web application into a new Maven web project. In traditional project JSPs are under WebApp/jsps folder, JavaScript & CS

2条回答
  •  心在旅途
    2020-12-15 23:21

    In a Maven project, firstly, you must add

    
    

    or

    
    

    to your servlet-config.xml file (it is spring-servlet.xml in my project).

    After that, construct a folder "resources" if it doesnt't exist under src/main/webapp. Put your CSS folder that contains CSS files, images folder that contains image files under the folder resources.

    Now you can access any file under resources folder from a JSP file as:

    
    

    or

    
    

    My spring-servlet.xml file:

    
    
    
      
      
    
      
      
    
      
    
      
      
         
            
          
      
    
      
      
            
      
    
      
      
    
      
     
       
     
    
    
    

    Project skeleton:

    src
    --main
      --webapp
        --resources
          --css+
          --images+
    --target
    

    ...etc

提交回复
热议问题