我是Spring MVC的新手。加载资源我使用@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
inflater.inflate(R.menu.custommenu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
。虽然这很好用,但现在却不行。我无法理解这个问题。谁能帮我?
这是我的spring-dispatcher-servlet.xml。 我的资源(设计)文件夹位于WebContent中,它有子文件夹,称为css,js和images。
< mvc:resources mapping="/design/**" location="/design/" />
这就是我在index.jsp
中加载资源的方法< beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="
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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
<context:component-scan base-package="controller"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="viewResolverhtml" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.html</value>
</property>
</bean>
<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="localhost"/>
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongo" ref="mongo"/>
<constructor-arg name="dabaseName" ref="testdb"/>
</bean>
<mongo:repositories base-package="model"/>
<mvc:view-controller path="/" view-name="index"/>
<mvc:resources mapping="/design/**" location="/design/" />
<mvc:annotation-driven/>
答案 0 :(得分:2)
尝试以下任何一项:
使用JSTL标记c:url
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link href="<c:url value="/design/css/reset.css" />" rel="stylesheet">
春天:url
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:url value="/design/css/reset.css" var="reset" />
没有任何标签
<link href="${pageContext.request.contextPath}/design/css/reset.css" rel="stylesheet"