请帮我解决问题。 请求将转到控制器类并获取视图名称,但无法显示带有错误的jsp。
当在浏览器中输入网址“http://localhost:8080/Spring_mvc_sep13/assetController”时,我在控制台上收到以下警告。
org.springframework.web.servlet.PageNotFound noHandlerFound
警告:在DispatcherServlet中找不到带有URI [/Spring_mvc_sep13/WEB-INF/Asset.jsp]且名称为“Disp”的HTTP请求的映射
web.xml如下
<servlet>
<servlet-name>Disp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Dispatcher-Beans.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Disp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Dispatcher-Beans.xml文件如下
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" ><value>/WEB-INF/</value></property>
<property name="suffix" ><value>.jsp</value></property>
</bean>
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean name="/assetController" class="org.pradeep.controller.AssetController"/>
<context:component-scan base-package="org.pradeep.controller"></context:component-scan>
<mvc:annotation-driven/>
控制器类如下
package org.pradeep.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
@Controller
@RequestMapping("/assetController")
public class AssetController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
ModelAndView mView = new ModelAndView("Asset");
return mView;
}
}
答案 0 :(得分:0)
我使用的是tomcat服务器7.0.30,java 1.8并且收到了此错误。 jsp没有被编译。因此我将服务器更改为7.0.68并解决了问题。