8

I can't understand why my Spring MVC page don't huck up bootstrap styles.

My hello.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>
    <link href="<c:url value="/bootstrap/css/bootstrap.min.css"/>" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>

<div class="btn-group">
    <button type="button" class="btn btn-default">Left</button>
    <button type="button" class="btn btn-default">Middle</button>
    <button type="button" class="btn btn-default">Right</button>
</div>

<script src="<c:url value="/bootstrap/js/bootstrap.min.js"/>"></script>
</body>
</html>

My directory project structure:

enter image description here

Any ideas how to properly add bootstrap?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user3279337
  • 451
  • 1
  • 6
  • 14

5 Answers5

3

If you are using Springs framework you can add these line in dispatcher-servlet.xml

<mvc:resources mapping="/bootstrap/**" location="/resources/" />
Manish Mahajan
  • 1,140
  • 1
  • 14
  • 38
0

Try using https://github.com/Mrdigs/Bootstrap.jsp

Its an open source JSP taglib designed to make working with Bootstrap and JSP simple, quick, and rewarding.

Darren
  • 1
0

It's also like my problem while using this BootStrap thing. in your folder-tree like that you wrote

    value="/bootstrap/css/bootstrap.min.css"

try

    value="bootstrap/css/bootstrap.min.css"

without using '/'

0

Another observation is that if you is using 'Eclipse", you must "refresh" your project after adding anything.

Ex.:
If you add some .js, you must "refresh" your project in eclipse
If you add some .css, you must "refresh" your project in eclipse

heronsanches
  • 524
  • 7
  • 12
0

spring mvc normaly load any source of external html libraries from the resource folder, located on your src distribution src->main->webapp->resource, Paste all your js, css there and link it to your jsp with

<link href="resources/css/yourResource.css" rel="stylesheet">