在配置文件中添加配置
<mvc:resources mapping=“/static/**” location=“/static/” />
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.test">context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".jsp"/>
bean>
<mvc:annotation-driven>mvc:annotation-driven>
<mvc:resources mapping="/static/**" location="/static/" />
beans>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<img src="static/images/timg.jpg" />
<h2>Hello World!h2>
<c:if test="${loginUser==null}">
请<a href="users/loginUi">登录a>
c:if>
<c:if test="${loginUser!=null}">
${loginUser.uname},欢迎您!
c:if>
body>
html>