I have couple of issues with my jsp.
Javascript and CSS dont get loaded using relative path
<head> <link rel="stylesheet" href="../css/bootstrap.min.css"/> <link rel="stylesheet" href="../css/mywebapp.css"/> <script src="../js/jquery-2.2.4.min.js" type="text/javascript"></script> <script src="../js/bootstrap.min.js" type="text/javascript"></script> <script> $(document).ready(function(){ ajaxdGetStats(); setInterval("ajaxdGetStats()",10000); }); </script>
Using the F12 I could figure out that the request for css and js goes to /css/bootstrap.min.css and /js/jquery-2.2.4.min.js whereas it should go to /mywebapp/css/bootstrap.min.css and /mywebapp/js/jquery-2.2.4.min.js
- The $(document).ready(function(){...}); throws an error below.
The value of the property '$' is null or undefined, not a Function object
My web directory structure is as below - enter image description here
I am using Spring MVC and below is my web.xml servlet configuration
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
and mvc-dispatcher-servlet.xml
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- resources exclusions from servlet mapping -->
<!-- <mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/js/**" location="/js/" /> -->