I have been searching on the net and ripping my hair on how to solve this issue for almost 3 weeks, but I can't find the reason why my static files are served in Spring MVC with tomcat 7 in my local Windows, but not in our server on Linux(Ubuntu). Below I have described my projects file structure and all my relevant files:
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/root-context.xml</param-value>
</context-param>
<listener>
<listener-class>com.bakuparkingaz.util.BakuParkingServletContext</listener-class>
</listener>
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>loginServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
app-context.xml:
<tx:annotation-driven />
<context:component-scan base-package="com.bakuparkingaz"/>
<context:property-placeholder location="classpath:db.properties" />
<mvc:resources mapping="/resources/**" location="/resources/"/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
AdminController.java:
@Controller
public class AdminController {
/.
@RequestMapping(value = "/admin")
public String admin() {
return "resources/admin/index.html";
}
}
So now when I call http://localhost:8080/admin I get the pretty styled page, but on the server http://8.8.8.8/project/admin (I have deployed my war file as project.war to tomcats webapp folder) results in an ugly styleless html page. Why my static files won't serve on the linux server?
UPDATE: admin/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/resources/admin/">
<meta charset="utf-8">
<title>BP Admin</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<link rel="stylesheet" href="css/semantic.min.css">
<link rel="stylesheet" href="css/my.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.4/css/jquery.dataTables.min.css">
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<div class="ui left vertical labeled icon menu sidebar" id="left-menu">
<a class="item">
<i class="home icon"></i>
Home
</a>
</div>
<div class="footer">
<div class="text center"><p>Copyright (c) 2015 - BakuParking</p> </div>
</div>
</div>
<script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" charset="utf-8"></script>
<script src="js/semantic.min.js"></script>
<script src="js/my.js"></script>
</body>
</html>