带有spring mvc的jsp中的源javascript文件<;3.0.4
我知道有人问过我这个问题,但这并没有解决我的问题,我尝试了很多事情都没有成功: 我的spring webapp项目目录非常标准,看起来像:带有spring mvc的jsp中的源javascript文件<;3.0.4,java,javascript,jsp,spring-mvc,servlets,Java,Javascript,Jsp,Spring Mvc,Servlets,我知道有人问过我这个问题,但这并没有解决我的问题,我尝试了很多事情都没有成功: 我的spring webapp项目目录非常标准,看起来像: /webapp/js/* eg. /webapp/js/query.jeditable.js /webapp/WEB-INF/jsp/* /webapp/WEB-INF/web.xml+ /webapp/WEB-INF/spring-servlet.xml - dispatcher servlet config /webapp/WEB-INF/spring
/webapp/js/* eg. /webapp/js/query.jeditable.js
/webapp/WEB-INF/jsp/*
/webapp/WEB-INF/web.xml+
/webapp/WEB-INF/spring-servlet.xml - dispatcher servlet config
/webapp/WEB-INF/spring-security.xml - spring security config
我试图从JSPURL中获取js中的javascript文件,该文件也通过SpringSecurityURL匹配器进行过滤。
这是我的web.xml:
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>Welcome to projectBananaStand</display-name>
<description>
Welcome to 'projectBananaStand' Add Event Test
</description>
<context-param>
<param-name>jmxLogEnabled</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/js/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>com.jpmorgan.tyger.listeners.JMXLog4JContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>registerName</param-name>
<param-value>projectBananaStand</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>500</error-code>
<location>/custError.jsp</location>
</error-page>
<distributable />
</web-app>
他们打破了spring安全默认登录页面加载。未找到spring安全登录页的资源错误
在jsp文件中尝试了不同的标记,包括
source="<c:url value="something" />"
source=“”
请帮助,我如何在没有mvc:resource-mapping
的情况下在jsp中包含javascript文件,或者如何使用mvc:resource-mapping
而不更改所有spring框架版本,只使用不同的
xmlns schemaLocation
并且不使用默认servlet带来spring安全性
有没有一种方法可以包含这些文件而不将它们视为URL?我做错了什么?
我将非常感谢您的帮助,因为我已经花了很多时间来解决这个问题。
谢谢将您的js文件夹保存在/WEB-INF/jsp/文件夹中,这可能是我没有尝试过的工作。我相信浏览器无法访问/WEB-INF/的内容
<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"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config />
<!-- declaring base package -->
<context:component-scan base-package="com.banana.controller" />
<mvc:annotation-driven/>
<!-- adding view resolver to show jsp's on browser -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value></property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean class="org.springframework.context.support.ResourceBundleMessageSource"
id="messageSource">
<property name="basename" value="messages" />
</bean>
</beans>
<mvc:resources mapping="/js/**" location="/js/" />
*.js, /js/**, and /somethingelse/*
source="<c:url value="something" />"