我是Spring mvc的新手,正在尝试学习它。我只想打印一条消息“ Hi Welcome to Spring MVC”,但出现此错误--->
HTTP状态404
描述原始服务器找不到目标资源的当前表示,或者不愿意透露该资源的存在。
任何帮助将不胜感激。
我正在使用Tomcat 9.0版本服务器
** WEB *
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Hello-servlet
<beans schema
<context:component-scan base-package="com.helloworld" />
<bean class
="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
HelloController
package com.helloworld;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value="/")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public ModelAndView printHello()
{
return new ModelAndView("hello","Hellomsg", "Hi Welcome to Spring
MVC");
}
}
我希望输出- 嗨,欢迎来到Spring MVC