0

我有这个页面welcome.jsp:

          <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";
}
  }

配置.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 中。

我真的陷入了这个问题。请帮帮我...

4

1 回答 1

0

我不确定你的控制器是否被调用,但我正在尽我所能

1.如果没有调用控制器:

检查 web.xml 并将 url 模式指定为 /

change if you have like this
   <url-pattern>*.html</url-pattern>
to
       <url-pattern>/</url-pattern>

2. 如果控制器调用:

Give suffix value (path of your jsps) of your view resolver as

  /WEB-INF/views or any other
于 2014-01-14T06:03:56.767 回答