Ho iniziato a fare un'app Web da zero. Prima ho sempre lavorato su app che erano già in esecuzione da molto tempo, quindi non ho avuto a che fare con la fase di installazione completa. Sto usando Spring 3 e Tomcat 6 e sto usando Eclipse 3.6Spring Tomcat e risorse statiche e mvc: risorse
Ho un grosso problema con le immagini di servizio (o altre cose diverse dalle risposte del controller). In effetti non riesco a trovare un modo per avere le mie immagini nei miei jsps. La mia configurazione, funziona con:
<servlet-mapping>
<servlet-name>springDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
in web.xml e
<bean name="/accise" class="it.jsoftware.jacciseweb.controllers.MainController">
</bean>
per il contesto servlet (più altri ovviamente).
Ho letto molti messaggi qui e altri forum a parlare di questo:
<mvc:resources mapping="/resources/**" location="/resources/" />
ma se inserisco che nella mia servlet-context.xml, sarò in grado di servire le immagini, ma il controllore " accise "non sarà raggiungibile. Sto abusando o ho frainteso l'etichetta delle risorse? Qual è il modo corretto?
Soluzione di aggiornamento trovata !!! :)
Il problema era che il mio servlet-config.xml perdere una sola dichiarazione:
Ora è (utilizzando le annotazioni sul controller):
<?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/" />
con questo le immagini funzionano ma molla non trova la mappatura per il controller (che trova senza il tag resources). context: componente-scan> \t \t –
gotch4
@ gotch4: Mostra il tuo 'MainController'. – axtavt
Gesù che dolore ... Questo deve essere registrato come un insetto in Primavera di sicuro. – sourcedelica