0
我有這個頁面的welcome.jsp:Spring MVC的URL不工作
<body>
<h1>Heading</h1>
<p>Tagline</p>
<p align="center">
<c:url var="homeLink" value="/home" />
<a href="${homeLink}" class="btn btn-success btn-large disabled">Get
Us Feeds Now</a>
</p>
</body>
</html>
但是,當我點擊鏈接,我不動回到Home.jsp 控制器針對home.jsp是:
@Controller
@RequestMapping(value = "/home")
public class HomeController {
@RequestMapping(method = RequestMethod.GET)
public String showForm() {
System.out.println("Called");
return "home";
}
}
的Config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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:component-scan base-package="com.controller" />
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views
directory -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="" />
<property name="suffix" value=".jsp" />
</bean>
請注意,我的網頁只在webcontent文件夾中,而不是在web-inf中。
我真的停留在這個問題上。請幫我...
你能粘貼你的config.xml嗎? – Mahendran
我已經添加了config.xml。 – user746458
這個jsp文件位於哪裏?如果它在/ WEB-INF下,那麼你需要給出 ' –
Mahendran