Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 将extJs导入JSP_Spring_Jsp_Spring Mvc_Extjs_Extjs4 - Fatal编程技术网

Spring 将extJs导入JSP

Spring 将extJs导入JSP,spring,jsp,spring-mvc,extjs,extjs4,Spring,Jsp,Spring Mvc,Extjs,Extjs4,我正在使用Spring工具套件,并创建了MVC应用程序。现在我想用这个概念来讨论ExtJs 但是我不能将extJs文件包含到JSP中 我的servlet如下所示: <mvc:resources mapping="/resources/**" location="/resources/" /> <beans:bean class="org.springframework.web.servlet.view.InternalReso

我正在使用Spring工具套件,并创建了MVC应用程序。现在我想用这个概念来讨论ExtJs

但是我不能将extJs文件包含到JSP中

我的servlet如下所示:

<mvc:resources mapping="/resources/**" location="/resources/" />

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="net.codejava.spingextjs" />
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
   <link href="resources/css/ext-all.css" rel="stylesheet">
   <script src="extjs/ext-debug.js" type="text/javascript"></script>
   <script src="app/app.js" type="text/javascript"></script>
</head>
<body>
</body>

我的JSP如下所示:

<mvc:resources mapping="/resources/**" location="/resources/" />

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="net.codejava.spingextjs" />
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
   <link href="resources/css/ext-all.css" rel="stylesheet">
   <script src="extjs/ext-debug.js" type="text/javascript"></script>
   <script src="app/app.js" type="text/javascript"></script>
</head>
<body>
</body>

文件夹树如下所示:

<mvc:resources mapping="/resources/**" location="/resources/" />

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="net.codejava.spingextjs" />
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
   <link href="resources/css/ext-all.css" rel="stylesheet">
   <script src="extjs/ext-debug.js" type="text/javascript"></script>
   <script src="app/app.js" type="text/javascript"></script>
</head>
<body>
</body>

但是页面不会加载,firelogger说/extjs/ext-debug.js和app/app.js不在服务器上(这些文件上有404)。我使用tomcat并在本地主机上进行了尝试

所以我的问题是,我应该如何在JSP中导入ExtJs,还是应该将home.JSP更改为home.html(尝试了这个,没有帮助)


我已经使用静态网页和html加载制作了ExtJs应用程序,但是我无法强制服务器使用MVC概念加载ExtJs。

您的js/css/图像需要位于
参考资料
文件夹中

有很多将ExtJS与Spring MVC结合使用的例子:

它依赖于旧版本的Ext,但它是一个很好的样板文件


干杯

您可能需要将extjs/ext-debug.js和app/app.js移动到resources目录中,因为其他位置将由dispatcher servlet处理

,如果不想移动这些文件,则在servlet配置中添加两行

<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/extjs/**" location="/extjs/" />
<mvc:resources mapping="/app/**" location="/app/" />

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="net.codejava.spingextjs" />

如果在配置文件中移动或添加了两行后,它无法解决问题,请尝试下面的jstl c:url标记

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
   <link href="<c:url value='/resources/css/ext-all.css' />" rel="stylesheet">
   <script src="<c:url value='/extjs/ext-debug.js' />" type="text/javascript"></script>
   <script src="<c:url value='/resources/css/ext-all.css' />app/app.js" type="text/javascript"></script>
</head>
<body>
</body>


为什么您认为更改源文件的文件扩展名会影响到您到其他文件(或文件不存在)的路径错误。这有什么逻辑意义吗?可能是我早上9点写的那篇文章的副本,我拼命想重新命名这个文件。谢谢,我在问之前尝试了所有这些,但没有按照我的需要工作。不过,进入资源和在app.js中更改路径有所帮助,谢谢。