Spring mvc Spring MVC url不工作
我有这个页面welcome.jsp:Spring mvc Spring MVC url不工作,spring-mvc,Spring Mvc,我有这个页面welcome.jsp: <body> <h1>Heading</h1> <p>Tagline</p> <p align="center"> <c:url var="homeLink" value="/home" />
<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>
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中
我真的陷入了这个问题。请帮帮我…我不确定您的控制器是否被呼叫,但我正在尽最大努力 1。如果未调用控制器: 检查web.xml并将url模式指定为/
change if you have like this
<url-pattern>*.html</url-pattern>
to
<url-pattern>/</url-pattern>
你也可以粘贴config.xml吗?我已经添加了config.xml。这个jsp文件在哪里?如果在/WEB-INF下,那么您需要给出
您是否尝试按照xml中的注释将jsp文件放入/WEB-INF/视图中?正如我在问题陈述中提到的,jsp文件仅直接位于WEB内容文件夹下。它们不在web inf文件夹或web inf/views文件夹中。请忽略xml文件中的注释。
change if you have like this
<url-pattern>*.html</url-pattern>
to
<url-pattern>/</url-pattern>
Give suffix value (path of your jsps) of your view resolver as
/WEB-INF/views or any other