我的情况如下:
MyApplication(folder)
|
| - server (folder)
| |
| | - some structure (folder)
| | |
| | - login.jsp
|
| - client (folder)
| |
| | - clientSoftware (folder)
| | |
| | | - index.html
| | | - something.html
| | | - otherSomething.html
我在Apache Tomcat服务器上运行它,我想得到的是:
本地主机:8080 / NameOfApplication / index.html中
而不是 本地主机:8080 / NameOfApplication /客户端/ clientSoftware / index.html中
我正在使用spring mvc。有没有办法做到这一点?
答案 0 :(得分:1)
具体看看example第6部分。
<bean name="/welcome.htm" .
class="com.mkyong.common.controller.HelloWorldController" />
注意当他们声明bean时,web url现在是http://localhost:8080/SpringMVC/welcome.htm
。
答案 1 :(得分:0)
那么,在Spring MVC中,如果你正在使用Annotation,那么
作为一个例子,
<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示例。