springmvc access static page 404

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/ethan__xu/article/details/80831307

First, check whether the spring-mvc.xml has been configured static resources

 

<mvc:resources mapping="/js/**" location="/resource/js/" />
<mvc:resources mapping="/css/**" location="/resource/css/" />
<mvc:resources mapping="/img/**" location="/resource/img/" />

When the front can not add a second step to reference a static resource page "/" otherwise they will not visit

 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<h2>Hello World!</h2>
<script type="text/javascript" src="js/index.js"></script>
<script>
    var add = function(){
        var url = "user/add";
        window.location.href = url;
    }
</script>
<link rel="stylesheet" href="css/index.css" />
<div style="width: 100px;height: 60px;color: cornflowerblue;cursor: pointer" onclick="add()">
    新增
</div>
<input type="button" value="编辑">
<input type="button" value="js" onclick="index.add()">
<div class="img">
    <img width="200px" height="300px" src="img/曹9.jpg">
</div>
</body>
</html>

 

 

 

Guess you like

Origin blog.csdn.net/ethan__xu/article/details/80831307