Can't include single CSS file with Jawr - java

So, we are using Jawr in our Spring project and all is working well, except that when I try to include a single css file like this:
<jwr:style src="/assets/css/style2.css" />
It includes all the files in the css directory
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/non-responsive.css?d=35303629" />
<script type="text/javascript">/* The resource '/assets/css/non-responsive.css' is already included in the page. */</script>
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style1.css?d=48250928" />
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style2.css?d=444574087" />
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style3.css?d=68336060" />
<script type="text/javascript">/* The resource '/assets/css/style3.css' is already included in the page. */</script>
<script type="text/javascript">/* Finished adding members resolved by /assets/css/style2.css */</script>
<script type="text/javascript">/* Start adding members resolved by '/assets/js/summary.js'. Bundle id is: '/assets/js/summary.js' */</script>
<script type="text/javascript" src="/assets/js/summary.js?d=82086305" ></script>
<script type="text/javascript">/* Finished adding members resolved by /assets/js/summary.js */</script>
This works well for single JS file as shown in the last two lines, but not for the CSS file for some reason.
Am I missing something, or should I just be including the file the traditional way?

Because everything inside assets/css/ is considered a variant skin by Jawr, so it loads all files.
You'll need to have only that style in the folder in order to load the single file.
For more information, see https://jawr.java.net/tutorials/howToUseJawrCssSkin.html , but the following part is an excerpt for your problem:
To define CSS skins, Jawr uses a directory hierarchy convention.
The user needs to define the default CSS skin root directory. All the directory defined at the same level will be considered as a skin variant.
To define the default skin root directory, the user must set the property jawr.css.skin.default.root.dirs.
This property defines the list of default CSS root directories. So with Jawr, you can handle mutliple CSS skin root directories.
For instance, if you define the default skin root directory as : /css/skins/defaultSkin.
And you have a directory structure like this :
If you set the Jawr configuration as:
jawr.css.skin.default.root.dirs=/css/skins/defaultSkin
Jawr will treat blueSkin and greenSkin as variants of defaultSkin.

Related

How to write the path so style.css can reload on my localhost page?

I m trying to create a sidebar where I have a style.css for customize it. When I inspect my page, it seems it never loads and get 404 not found.
<head>
<h1>sidebar</h1>
<title>Responsive Sidebar Menu</title>
<link rel="stylesheet" type="text/css" href="style.css"></head>
My project is structured like in the following picture:
I can't figure out how to write the path so it can load properly.
Move your template folder right under resources:
src/main/resource/static/css (for CSS files);
src/main/resource/templates (for HTML templates).
Then correct the link tag as follows:
<link href="../static/css/style.css" th:href="#{/css/style.css}" rel="stylesheet" />

Problem with paths accessing CSS with Spring and Apache FreeMarker

I'm having a problem trying to access my static CSS resources from lower directories. If I am in the main directory it detects everything but if I go to other lower directories, it adds the path from that folder and does not detect them.
Error
(In that path "server" is a directory that should not appear, since css is in the main directory)
<link rel="stylesheet" href="/css/bootstrap.min.css">
<!-- Bootstrap CSS
============================================ -->
<link rel="stylesheet" href="/css/font-awesome.min.css">
I tried from putting ../, ./ searching the internet but I didn't find anything.
I am using Apache FreeMarker
Use .. to indicate the parent directory:
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/font-awesome.min.css">
This will help you.

CSS file not found on GET request

I have a project with such structure. CSS file is included like this
<link rel="stylesheet" type="text/css" href="../static/css/style.css"/>
When I open html file on it's own from my computer, css loads. But when i load it from GET request on localhost, css file is not found.
It is indeed a path mistake.
When you are using two dots before slash sign - browser searches for the file in two folders upper from the current place of index.html
The solution depends on where your index file is located, I think that when you put all the thing to localhost your index.html is in the root folder, so there is no need in dots before the slash sign, simply make your path like this:
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
Or without "/static/", if you have also moved "css" folder to the root
If you are still calling index from the templates folder - try using this code
<link rel="stylesheet" type="text/css" href="./static/css/style.css"/>
Your path is incorrect. From the image the correct path seems to be
<link rel="stylesheet" type="text/css" href="../static.css/style.css"/>

How to organise files inside a folder in Netbeans IDE

I want to keep all CSS files in one folder and I want to access them. Below is the path of my CSS folder
css/sampl.css. Where css is the folder.
This is my code:
<link href="/CSS/sampl.css" rel="stylesheet" type="text/css" />
I can't access the sampl.css file. Could somebody help me out?
You are missing a context path in the URL. To prepend a context path you can use JSP EL
<link href="${pageContext.request.contextPath}/CSS/sampl.css" rel="stylesheet" type="text/css" />
The CSS folder is in the web application root.

Include css in struts2 jsp page

My struts2 project structure as follows
Webcontent
css
abc.css
jsp
login.jsp
META-INF
WEB-INF
indeed to include the functions of abc.css in login page.How can i do that ? How can i give the path of css file in jsp page ?
Include your css with the following statement.
<head>
<link rel="stylesheet" type="text/css" href="../css/abc.css">
</head>
"../css/abc.css" is a relative path.
"../" represents one directory up. i.e., Login.jsp is in "jsp" directory "../" will make the directory as "Webcontent"
"../css" will traverse you upto "css" directory in the "Webcontent".
"../css/abc.css" will give the abc.css file.
you can include your css file like this.
<head>
<link rel="stylesheet" type="text/css" href="/Webcontent/css/abc.css">
</head>

Categories

Resources