我是 spring mvc 的新手,正在尝试开发一个非常基本的登录 webapp。运行项目时出现以下错误。自上两周以来,我几乎尝试了所有方法,但无法修复此错误。请有人可以帮助我。
May 21, 2013 2:37:12 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringWeb/WEB-INF/jsp/loginnn.jsp] in DispatcherServlet with name 'spring'
我的 jsp 页面位于 WEB-INF/jsp 下。我的控制器中的方法 loginpage 正在被调用,但视图名称没有被呈现和解析。非常感谢您的帮助。
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>testspring</display-name>
<servlet>
<servlet-name>frontcontrol</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>frontcontrol</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
前端控制-servlet.xml
<context:component-scan base-package ="com.shell.spring.testspringapp">
</context:component-scan>
<bean id ="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
控制器类
@Controller
public class Firstcontrol {
@RequestMapping(value="/")
public ModelAndView invokeme(Model m)
{
ModelAndView mav=new ModelAndView();
mav.setViewName("result");
System.out.println("In method");
return mav;
}
@RequestMapping(value="/submit" ,method=RequestMethod.GET)
public String submit(Model m)
{
System.out.println("In submitmethod");
return "submit";
}
}