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?

4

2 に答える 2

1

この例、特にパート 6 を見てください。

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

http://localhost:8080/SpringMVC/welcome.htmBean を宣言すると、Web URL がどのようになるかに注目してください。

于 2013-09-05T16:37:05.663 に答える
0

さて、Spring MVC では、アノテーションを使用している場合は、

例として、

HTML

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

スプリングコントローラー

@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.

また、この関数を呼び出すためのマッピングが何であれ、ユーザーには表示され、実際のページは mnv を返すものです。

   }
}

ディスパッチャーファイル

<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>

web.xml に Spring MVC Dispatcher クラス マッピングを追加します。web.xml の変更については、Spring MVC の例をご覧ください。

于 2013-09-05T18:29:59.250 に答える