简体   繁体   English

将CSS和javascript文件放在Gradle Java Web应用程序中的位置

[英]Where to put css and javascript files in gradle java web application

I followed the steps for building java web application using the following guide https://guides.gradle.org/building-java-web-applications/ 我使用以下指南https://guides.gradle.org/building-java-web-applications/遵循了构建Java Web应用程序的步骤。

Now there is no web.xml generated. 现在没有生成web.xml。 Trying to find out where to put my css and javascript files so that they can be accesible in jsp and html. 尝试找出将我的CSS和javascript文件放在哪里,以便它们可以在jsp和html中使用。

Static resources should go in src/main/webapp. 静态资源应该放在src / main / webapp中。 Anything in this folder will be copied into the root of the war file. 此文件夹中的所有内容都将复制到war文件的根目录中。

For Example, if you place the following index.html and site.css in src/main/webapp, you should get a page with Hello, World in blue text. 例如,如果将以下index.html和site.css放置在src / main / webapp中,则应该获得一个带有Hello,World的蓝色文本页面。

index.html index.html

    <html>
    <head>
        <link href="site.css" />
    </head>
    <body>
        <h1>Hello, World</h1>
    </body>
    </html>

site.css site.css

    h1 {
        color: blue;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM