我开始从零做一个Web应用程序。以前我总是在处理已经运行了很长时间的应用程序,所以我不需要处理完整的设置阶段。我正在使用Spring 3和Tomcat 6,并且我正在使用Eclipse 3.6。
我在处理图像(或其他与控制器响应不同的内容)时遇到了大问题。事实上,我找不到一种方法来在我的JSP中放置我的图像。我的配置可以使用以下方式进行操作:
我在处理图像(或其他与控制器响应不同的内容)时遇到了大问题。事实上,我找不到一种方法来在我的JSP中放置我的图像。我的配置可以使用以下方式进行操作:
<servlet-mapping>
<servlet-name>springDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
在 web.xml 文件中
<bean name="/accise" class="it.jsoftware.jacciseweb.controllers.MainController">
</bean>
针对servlet上下文(当然还有其他内容)。
我在这里和其他论坛上读到很多关于这个问题的帖子:
<mvc:resources mapping="/resources/**" location="/resources/" />
但是如果我在我的servlet-context.xml中插入这个,我就能够提供图片,但是控制器“accise”无法到达。我是否使用不当或者误解了资源标记?正确的方式是什么?
更新已找到的解决方案!!! :)
问题在于我的servlet-config.xml缺少一个声明:
现在是(在控制器上使用注释):
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
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-2.5.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
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">
<context:component-scan base-package="it.jsoftware.jacciseweb.controllers"></context:component-scan>
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<mvc:resources mapping="/resources/**" location="/resources/" />
MainController
,@gotch4。 - axtavtDispatcherServlet
的javadoc中有描述。而且,它不会影响到注释控制器,只会影响到按bean名称映射的控制器。 - axtavt