Jia*_*ang 3 java spring jsp spring-mvc
实际上,我有一个欢迎页面(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";
}
Run Code Online (Sandbox Code Playgroud)
这是我的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/" />
Run Code Online (Sandbox Code Playgroud)
这是"welcome.jsp"中的链接:
<a href="contactinfo">Contact us</a>
Run Code Online (Sandbox Code Playgroud)
好的,我发现答案是 <a href="contactinfo">Contact us</a>
@RequestMapping("/contactinfo")
public String contactinfo() {
return "contactinfo";
}
Run Code Online (Sandbox Code Playgroud)