1

I'm new to java. And now I'm doing Struts2 project. I added stylesheet in this path

/WEB-INF/common/css/style.css

and added bootstrap in this path

/WEB-INF/common/css/bootstrap/bootstrap.min.css

and included them in JSP file as

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="/WEB-INF/common/css/bootstrap/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/WEB-INF/common/css/style.css" rel="stylesheet" type="text/css">
<title>Login</title>

But css doesn't work when I run the program. What do I need to do in Struts2 to include CSS files?

Roman C
  • 49,761
  • 33
  • 66
  • 176
user3898594
  • 123
  • 2
  • 4
  • 8

4 Answers4

1

The CSS file path is depending upon where your JSP files are located. Share your project folder structure.

For example:

Application name
   |
   | - WEB_INF
   | - JSP -(If this folder having JSP files)
   | - common/css
   | - JS

Then the path of CSS in JSP file is like

<link href="../common/css/style.css" rel="stylesheet" type="text/css">

Here single .(dot) represent current directory that is JSP Direcrory(Folder)

and double ..(dot) previous/upper directory that is Application/Main project directory, from this directory its points to /common/css/style.css

Girish
  • 107
  • 3
  • 10
1

You need to move your css files out of the WEB-INF directory since it is not public. Here is a good explanation of what WEB-INF is and how it should be used: What is WEB-INF used for in a Java EE web application?

Community
  • 1
  • 1
hermansen
  • 158
  • 3
1

First put all css file and js file put in one JSP page and then that jsp page include in jsp page using tag...

fine i.e.<%@include file="header.jsp"%>

0

you can't include CSS files in /WEB-INF path, take it in the web root path ,and use /common/css/style.css to access your page

davidtall
  • 13
  • 4
  • Thanks. I changed the directory and it works now. But only the input type button doesn't change although I styled it in the same style sheet – user3898594 Nov 21 '14 at 07:43
  • clean up your browse cache ,and check the file bootstrap.min.js ,the bootstrap should include js file. – davidtall Nov 21 '14 at 07:56