【发布时间】:2019-03-08 17:20:42
【问题描述】:
我是 Spring + MVN 的新手。 我现在有一个带有控制器的项目,我想与 JSP 页面“连接”。这里有项目结构:
我有 Web-servlet.xml,其中包含:
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
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">
<context:component-scan base-package = "com.ms.TicketsSystem" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property> </bean>
</beans>
还有 web.xml:
<web-app id = "WebApp_ID" version = "2.4"
xmlns = "http://java.sun.com/xml/ns/j2ee"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Form Handling</display-name>
<servlet>
<servlet-name>Web</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Web</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
控制器:
@Controller
public class WebController {
@RequestMapping(value="/add")
public String addTicket(){
/*
TODO
*/
return "add";
}
}
当我转到localhost:8080/add 时,它正在显示
Error resolving template [add], template might not exist or might not be accessible by any of the configured Template Resolvers
关于我做错了什么有什么建议吗?
【问题讨论】:
标签: java spring maven jsp templates