实际上,我有一个欢迎页面(welcome.jsp)。欢迎页面中有一个名为“联系我们”的链接。我也有contactinfo.jsp。我想将链接(联系我们)连接到contactinfo.jsp。如何使其运作?
我已经尝试过了,但是没有用。欢迎页面正在运行,但是我单击了“联系我们”链接,而不是contactinfo.jsp。看到下面是欢迎控制器:
@RequestMapping("/")
public String welcome(Model model) {
model.addAttribute("greeting", "Welcome to Luke's Book Store!");
model.addAttribute("tagline", "The one and only amazing web store");
return "welcome";
}
@RequestMapping("/contactinfo")
public String contactinfo() {
return "contactinfo";
}
这是我的dispatcherServlet:
<mvc:annotation-driven enable-matrix-variables="true"/>
<context:component-scan base-package="com.jiachangyang.ebookstore" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id= "messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
<mvc:default-servlet-handler />
<mvc:resources mapping="/css/**" location="/WEB-INF/css/" />
这是“ welcome.jsp”中的链接:
<a href="contactinfo">Contact us</a>
好,我知道答案是 <a href="contactinfo">Contact us</a>
@RequestMapping("/contactinfo")
public String contactinfo() {
return "contactinfo";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句