Printemps:url de ne pas résoudre correctement les liens

Je suis assez nouveau dans le cadre du Printemps et des applications web, mais je suis expérimenté en Java. Quand je lance mon site en local serveur tomcat l'URL est: http://localhost:8080/myApp/

Maintenant une demande de cartographie des délégués moi à ma page d'accueil avec:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String someMethod(Model model) { ... 
   return "index"; }

Maintenant dans un fichier index.xhtml j'ai un lien vers une autre page avec <a href="apps/">link</a>
mais quand je veux faire un lien vers la page d'index-je utiliser <a href="../index/">link</a>. J'ai cherché une solution et trouvé:

<spring:url value='/apps' var="apps_url" />
<a href="${apps_url}">link</a>

Mais le printemps:l'url des résout toujours à http://localhost:8080/myApp/ - la page que je suis actuellement sur. En outre, lorsque j'utilise juste un lien comme ceci: <a href="/otherSite">link</a>, il résout toujours à http://localhost:8080/otherSite et pas http://localhost:8080/myApp/otherSite comme je l'ai prévu. Comment puis-je obtenir mon lien pour le travail? Est http://localhost:8080/myApp définis implicitement que mon contexte ou peut/doit-il être changé pour http://localhost:8080/?

Aussi, est-il un lien entre l'URL sur local serveur tomcat et l'URL de l'application web aura quand c'est publié?

Voici quelques unes de mes fichiers de l'application:

servlet-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="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-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <context:component-scan base-package="myApp" />

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <!-- Handles HTTP GET requests for /resources/** and /css/** by efficiently 
    serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />
    <resources mapping="/css/**" location="/css/" />

    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".xhtml" />
    </beans:bean>

</beans:beans>

extrait de web.xml:

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

OriginalL'auteur jeyp | 2012-02-17