0

The structure looks like -

projectroot -- src --> main-->java-->com-->controllers etc
            -- src --> resourcess--> myresources --> css-->.css
            -- src --> resourcess--> myresources --> images-->.jpg etc
            -- src --> webapp --> mvc-dispatcher-servlet.xml
            -- src --> webapp --> pages --> .jsp pages

Top of the page contains -

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html>
<head>

I am using following in head section of page -

<link
    href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"
    rel="stylesheet">
<link
    href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"
    rel="stylesheet">
<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet">

Images like -

<img    src="/resources/images/logo2.png" height=20;></a>

mvc-dispacther-servlet contains -

<bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/pages/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

    <mvc:resources mapping="/resources/**" location="/resources/myresources/" />
    <mvc:annotation-driven />

There is no error in console as such, but I don't see page being displayed properly. Any suggestions as why images and css aren't getting uploaded? Isn't mvc-dispatcher mapping for resources not correct as per my project directory structure? Thanks for any help on this.

lets.learn
  • 169
  • 1
  • 1
  • 8

1 Answers1

0

Move your resources folder under webapp like this:

projectroot -- src --> main-->java-->com-->controllers etc
            -- src --> webapp --> mvc-dispatcher-servlet.xml
            -- src --> webapp --> pages --> .jsp pages
            -- src --> webapp --> resources--> myresources --> css-->.css
            -- src --> webapp --> resources--> myresources --> images-->.jpg etc
alfreema
  • 1,308
  • 14
  • 26
  • worked like a charm. Just wondering what the default resources folder is used for. Thanks a lot. – lets.learn Mar 14 '15 at 06:04
  • found this one very helping - [here](http://stackoverflow.com/questions/13376473/accessing-resources-in-jsp-page-of-spring-mvc-app) – lets.learn Mar 14 '15 at 06:05