Angularjs 在名为的DispatcherServlet中找不到URI为的HTTP请求的映射
我不知道如何将css链接到js文件 请帮我收拾一下。我只收到以下请求: 在名为“library”的DispatcherServlet中找不到URI为[/LiblaryProject/WebContent/js/script.js]的HTTP请求的映射 library-servlet.xml:Angularjs 在名为的DispatcherServlet中找不到URI为的HTTP请求的映射,angularjs,spring,spring-mvc,Angularjs,Spring,Spring Mvc,我不知道如何将css链接到js文件 请帮我收拾一下。我只收到以下请求: 在名为“library”的DispatcherServlet中找不到URI为[/LiblaryProject/WebContent/js/script.js]的HTTP请求的映射 library-servlet.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:mvc="http://www.springframework.org/sc
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.myliblary.*" />
<bean id="UserDAO" class="com.myliblary.dao.UserDAOImpl">
<constructor-arg>
<ref bean="sessionFactory" />
</constructor-arg>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/liblarydb" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<mvc:annotation-driven/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/Pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
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" >
<servlet>
<servlet-name>library</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>library</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
图书馆
org.springframework.web.servlet.DispatcherServlet
1.
图书馆
/
在my Home.jsp中,我有如下内容:
<script src="<c:url value="WebContent/js/script.js" />"></script>
<link href="/css/custom.css" rel="stylesheet" type="text/css" />
通过使用url模式/您已经覆盖了容器的默认servlet。这是一个servlet,它从web应用程序的根目录提供静态内容。要保持映射,需要配置Spring默认servlet处理程序。其工作原理是,对静态资源的请求现在通过Spring而不是默认的servlet发出。Spring现在将根据容器类型查找容器defualtservlet。要实现这一点,请将下面的行添加到应用程序配置文件中
<mvc:defualt-servlet-handler/>
在控制器中接受诸如“/”之类的请求,因为在web.xml中是这样的。尝试更改此选项: 例如: Web.XML:
<servlet-mapping>
<servlet-name>library</servlet-name>
<url-pattern>.*htm</url-pattern>
</servlet-mapping>
图书馆
*htm