- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我目前正在使用 spring MVC 开发一个基于 JavaEE spring 的应用程序,但是当我添加 css 和 js 文件时,jsps 不读取它们,经过一些研究后,我在我的调度程序 servlet 文件中添加了这一行
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.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.3.xsd">
<context:component-scan base-package="controllers"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources>
</beans>
这是元素层次结构
最佳答案
试试这个,
在你的 jsp 页面上,如果你使用的是 jSTL 那么就这样做
首先包含jSTL标签库,
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
然后
<link href="<c:url value="/resources/css/myCSSFile.css" />" rel="stylesheet">
<script src="<c:url value="/resources/js/jquery.1.10.2.min.js" />"></script>
<script src="<c:url value="/resources/js/main.js" />"></script>
比如说,如果你已经在使用 Spring 标签库,那么你可以这样做吗,
首先引入标签库,如下
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
然后这样做,
<s:url value="/resources/css/main.css" var="mainCss" />
<s:url value="/resources/js/jquery.1.10.2.min.js" var="jqueryJs" />
<s:url value="/resources/js/main.js" var="mainJs" />
<link href="${mainCss}" rel="stylesheet" />
<script src="${jqueryJs}"></script>
<script src="${mainJs}"></script>
如果我在这里遗漏了要解释的内容,请告诉我
关于javascript - 如何使用 spring Mvc 添加带有 jsps 的 css 和 js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43740408/
我想知道 Spring 中是否有某种方法可以在 Controller 中指定我想将客户端发送到我用于 View 的 .jsp 页面中的特定 anchor 。 我的 .jsp 页面中有一个部分,由 #e
我目前正致力于将现有的 Web 应用程序转换为支持其他语言(即威尔士语)。我建议的方法是将所有显示的文本提取到属性文件中,然后使用 JSTL fmt 标签访问文本。 我的问题是:这些属性文件应该如何构
首先: 我收到警告:“未定义的属性名称 (xmlns)。”在 Eclipse 中解决此问题的最佳方法是什么? 我在这里还收到错误“属性值缺少引号(它指的是中心) 两个
我的构建 gradle 看起来像这样 buildscript { repositories { maven { url "http://repo.spring.io/libs-
我有一个同时使用 .jsps 和 servlet 的项目。我在两个文件之间转发请求时遇到困难:注册表单(jsp)和注册 servlet。 servlet 验证通过表单接收的数据并处理用户创建。如果注册
我的问题是关于 Liferay 钩子(Hook)和 portlet 6.0。 我有 jsps 覆盖 liferay portlet 的钩子(Hook)。例如document_library/view.
我的 Web 应用程序的架构是高度模块化的。我使用 apache 瓦片作为模板框架。应用程序模块捆绑为不同的 jar 文件并放在 WEB-INF/lib 文件夹中。所以每个jar文件都会包含自己的ti
我现在正在为 Web 应用程序编写 ANT 脚本(而且我对 ant 脚本和 weblogic 服务器管理知之甚少)。 当我执行 ant 脚本时,除了脚本无法预编译 jsps 之外,一切正常。 PFB
我在我的项目中使用 JSTLView Spring Tiles。 当我尝试通过 Controller 将 form:errors 从 validator 发送到 jsp 时,jsp 中不会显示错误 当
我在使用 apache tomcat 8.0 时遇到以下问题: Sep 02, 2015 12:20:33 PM org.apache.jasper.compiler.JDTCompiler$1 fi
我在 QA 中发现了 JBoss 4.2 上的这种令人讨厌的行为,我想在我们投入生产之前将其消灭在萌芽状态并找到其他一些极端情况。 jsp 调用具有以下签名的方法: public void meth
这个不是很短,所以请多多包涵。 我正在使用 Spring 3.0、Apache Tiles 2.2 和 Spring WebFlow 2.2 开发一个 Web 应用程序。一个重要的要求是它需要非常模块
我们正在使用 jspc ant task 将 JSP 文件预编译成类/(然后打包成 war) 现在我们切换到 Jetty 8。根据文档,有一个 maven 插件可以做 this .我们有 Ant 任务
有谁知道如何从 Spring 3 发送由 View (jsp)创建的电子邮件吗? (spring手册描述了如何使用Velocity作为模板引擎来生成电子邮件正文,但是否也可以使用JSP代替?) 最佳答
我正在使用 spring mvc + spring security 构建一个简单的 web 应用程序。我实现了登录/注销(spring mvc),但我还想提供一个可直接从 login.jsp 访问的
我的应用程序是一个基于网络的报告工具。这些报告是根据从 jsps 接收到的一些输入参数生成的。结果通过 Servlet 处理,然后使用 jsps 再次显示。 现在在报告页面上我们需要一个按钮,单击该按
我有一个要求,我必须为一个变量分配一个值,该变量应该由另一个 jsp 访问,该 jsp 将从该 jsp 调用。详细说明: 我有一个 html 字段,它是一个下拉列表,其列表值始终是常量。它的意义在于,
我可以为两个jsp使用一个请求映射吗? 我当前正在从一个 Controller 调用一个请求映射,但其中一个 jsps 似乎没有被 Controller 捕获。 两个jsp具有相同的表单操作和相同的表
让有一个(Liferay hook 插件)eclipse 项目 xyz-hook。并让文件a.jsp 并让另一个(引用的)项目中包含包含的 init.jsp。 对于项目 xyz-hook 中的
我有一个 accountType 变量,它是在用户登录到我的网络应用程序时设置的。 在我的许多 jsps 上,我需要检查 accountType 的值,以便我可以相应地显示(或不显示)各种内容。 目前
我是一名优秀的程序员,十分优秀!