【问题标题】:css is not applyingcss 不适用
【发布时间】:2016-09-20 10:56:15
【问题描述】:

这是我的 Spring 控制器

@RequestMapping(value = "/board/{id}" ,method=RequestMethod.GET)
public String scrumboard(@PathVariable("id") String id) { // if I change    string to key error occurs
    System.out.println(id); //123
    return "html/board";
}

这是我的 HTML 代码。

<a class='scrumboard' href='/board/123'>

问题:

<a class='board' href='/board'>

如果我使用上面的语句,我可以成功获取board.jsp页面。

<a class='board' href='/board/123'>

如果我用 id 传递它,我可以检索 board.jsp 页面,但 CSS 和 JS 文件不适用。在我的代码中,id 是动态生成的。

【问题讨论】:

  • 我在 Eclipse 中使用 SpringTool Suite 并处理 Spring 遗留项目。

标签: html css spring jsp


【解决方案1】:
<mvc:resources mapping="/resources/**" location="/resources/theme-new/" />

将此行放入您的 spring-config.xml 文件中。并在 location 属性中更改您的位置。

【讨论】:

  • 我已经有这样的了。 它映射到我所有与我的项目相关的jsp文件都存在的位置。如果我用
  • 在位置设置你的css文件夹路径。
  • location="/WEB-INF/html/index.jsp" 到 location="/WEB-INF/css/**" 或类似的东西。
  • 是的。其实我不了解资源映射。所以我直接将我的文件放在网络应用程序文件夹中并使用它。现在我将我的静态文件移动到资源目录并进行配置。它工作正常。
猜你喜欢
  • 2020-06-14
  • 2013-04-23
  • 2019-09-10
  • 2014-12-23
  • 2018-12-26
  • 2017-12-19
  • 2013-08-03
  • 2012-10-03
  • 2014-08-07
相关资源
最近更新 更多