mvc中+css,SpringMVC在JSP中加载CSS等静态资源问题

大家好,我的问题是这样的。

自己搭建了SpringMVC + Spring + Hibernate 框架。

结果在JSP中引用CSS等静态文件的时候遇到了404的问题。

以下是问题的截图。以及配置文件的信息。

还有就是我查了很多资料。SpringMVC加载静态资源的三种配置我都已经试过了但是都不好使。

比如这个链接的内容 三种方式都不好使。

问题情况如下:

bVuF8Q

项目结构:

bVuF8U

SpringMVC配置文件:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd

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-4.2.xsd">

expression="org.springframework.stereotype.Controller" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

web.xml:

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

index.jsp

contextConfigLocation

classpath:applicationContext.xml

org.springframework.web.context.ContextLoaderListener

dispatcherServlet

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

1

dispatcherServlet

/

characterEncodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

characterEncodingFilter

/

log4jConfigLocation

classpath:log4j.properties

log4jRefreshInterval

6000

org.springframework.web.util.Log4jConfigListener

openSession

org.springframework.orm.hibernate4.support.OpenSessionInViewFilter

openSession

/*

jsp:

String path = request.getContextPath();

String basePath = request.getScheme() + "://"

+ request.getServerName() + ":" + request.getServerPort()

+ path + "/";

%>

My JSP 'work_info.jsp' starting page

WELCOME TO WORKSPACE

watch.png

Controller:

//就只粘贴了有用的部分

package com.whr.Controller;

import java.sql.Date;

import java.util.List;

import org.apache.log4j.Logger;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

import com.whr.Entity.Work;

import com.whr.Service.WorkService;

@Controller

@RequestMapping("/work")

public class WorkController {

@Autowired

private WorkService workService;

private static Logger logger = Logger.getLogger(WorkController.class);

@RequestMapping("/index")

public String workIndex()

{

return "testIndex";

}

@RequestMapping("/index2")

public String workIndex2()

{

return "work";

}

大概情况就是这样的了。

弄了两天了,方法试了好多,简直焦头烂额。各位大神帮帮忙看看吧,不胜感激!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值