JavaScript with Spring MVC not working

I downloaded a login template that uses css and javascript. When I run it in html format by default, it displays fine, but when I put the same code in my Spring MVC 3 application and change the format to jsp, the javascript part is disabled. I can access external js files through my web browser, so I don't know where the problem might be.

This is the correct view: right

but this is what I get: wrong

<script language="javascript" type="text/javascript" src="js/niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" />

I just changed the location of the external js and css resources, but these files are available, as I said.

This is my structure:

enter image description here

In mine web.xml, I have the following lines:

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring/root-context.xml,
        /WEB-INF/spring/security-context.xml,
    </param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<!-- Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.txt</url-pattern>
</servlet-mapping>

I also use Apache tiles2

<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/views/layout/layout.jsp">
    <put-attribute name="body" value="" />
</definition>

<definition name="contact" extends="base.definition">
    <put-attribute name="body" value="/WEB-INF/views/contact.jsp" />
</definition>

<definition name="login" template="/WEB-INF/views/login/login.jsp">
</definition>

Thank.

Edit:

, , , ... css. - : body {background-image:url('images/bg.jpg');} firebug, localhost: 8080/sheedo/css/images/bg.jpg, , body {background-image:url('/images/bg.jpg');} , localhost: 8080/images/bg.jpg. ./images/bg.jpg, , - , css ? - <mvc:resources ... >, ?

+3
4
<script type="text/javascript" src="${pageContext.request.contextPath}/js/niceforms.js"></script>
<link href="${pageContext.request.contextPath}/css/niceforms-default.css" rel="stylesheet" />

. , ..

+8

jsps javascript css

jsp

<%
    String path = request.getContextPath();
%>

<script language="javascript" type="text/javascript" src="<%=path%>/js/niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="<%=path%>/css/niceforms-default.css" />
+1

${pageContext.request.contextPath}, :

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

:

<spring:url value="/resources/jquery-2.1.4.js" var="jqueryJS" />
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
    var script = document.createElement('script');
    script.type = "text/javascript";
    script.src = "${jqueryJS}";
    document.getElementsByTagName('head')[0].appendChild(script);
}
</script>
0

All Articles