0

my situation looks like this:

MyApplication(folder)
|
| - server (folder)
|      |
|      | - some structure (folder)
|      |     |
|            | - login.jsp
|
| - client (folder) 
|     |
|     | - clientSoftware (folder)
|     |     |
|     |     | - index.html
|     |     | - something.html
|     |     | - otherSomething.html

I'm running it on Apache Tomcat server and what I would like to get is this:

localhost:8080/NameOfApplication/index.html

and not localhost:8080/NameOfApplication/client/clientSoftware/index.html

I'm using spring mvc. Is there any way to do this?

iie
  • 501
  • 4
  • 8
  • 26
  • You are using Spring MVC and Apache server... I hope it would be Apache Tomcat right, please clear because if you are using only Apache Web Server then I don't think you will be left with any solution... – Jayesh Sep 05 '13 at 16:32
  • well but of course, sorry. Just correct it = ) – iie Sep 05 '13 at 16:35
  • seems related to me: http://stackoverflow.com/a/1563808/2636001 – dst Sep 05 '13 at 16:37

2 Answers2

1

Take a look at this example specifically part 6.

<bean name="/welcome.htm" .
     class="com.mkyong.common.controller.HelloWorldController" />

Notice how the web url is now http://localhost:8080/SpringMVC/welcome.htm when he declares the bean.

Grammin
  • 11,808
  • 22
  • 80
  • 138
0

Well, In Spring MVC, If you are using Annotation then,

As an Example,

HTML

<a href="cabBooking">Book Cab</a>

Spring Controller

@Controller
public class HomeController {

@RequestMapping(value="/cabBooking", method = RequestMethod.GET)
    public ModelAndView getCabBookingPage() {

        ModelAndView mnv = new ModelAndView("cabBooking"); //here it will search "cabBooking.jsp" in /WEB-INF/pages/ and same mapping you can find in dispatcher file.

Also, whatever your mapping is to invoke this function will be visible to user and actual page is what you will p return mnv;

   }
}

dispatcher file

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-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:annotation-config />
    <context:component-scan base-package="com.on.transport" />
    <mvc:annotation-driven />

    <bean
       class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/pages/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>

Add Spring MVC Dispatcher class mapping in web.xml. Have a look at any Spring MVC example for web.xml changes.

Jayesh
  • 6,047
  • 13
  • 49
  • 81