简体   繁体   English

春季3.2.0没有uri

[英]Spring 3.2.0 no uri found

Following is: 以下是:

appServlet-servlet.xml appServlet-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:cache="http://www.springframework.org/schema/cache" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc.xsd 
        http://www.springframework.org/schema/cache 
        http://www.springframework.org/schema/cache/spring-cache.xsd">


    <!-- DispatcherServlet Context: defines this servlet's request-processing 
        infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <!-- <annotation-driven /> -->
    <!--  <context:annotation-config /> -->

      <mvc:annotation-driven />
    <context:component-scan base-package="com.interlace"/>


</beans:beans>

web.xml web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" >




<servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        </servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>




</web-app>

HelloController.java HelloController.java

@Controller
@RequestMapping("/welcome")
public class HelloController  {

    @RequestMapping("/hello")
    public ModelAndView helloWorld(HttpServletRequest arg0,
            HttpServletResponse arg1) throws Exception {
        return new ModelAndView("/HelloWorld.jsp");
    }

}

No mapping found for HTTP request with URI [/HelloWorld/welcome/hello] in DispatcherServlet with name 'appServlet' I am using spring 3.2.0 if have added all required jar files.I am using without maven.Please try to help me 在名为'appServlet'的DispatcherServlet中找不到带有URI [/ HelloWorld / welcome / hello]的HTTP请求的映射。如果添加了所有必需的jar文件,我正在使用spring 3.2.0。我没有使用maven。请尝试帮助我

From spring references documentation: 从Spring参考文档中:

The DispatcherServlet is an actual Servlet (it inherits from the HttpServlet base class), and as such is declared in the web.xml of your web application. DispatcherServlet是一个实际的Servlet(它继承自HttpServlet基类),因此在Web应用程序的web.xml中声明。 You need to map requests that you want the DispatcherServlet to handle, by using a URL mapping in the same web.xml file. 您需要通过在同一web.xml文件中使用URL映射来映射希望DispatcherServlet处理的请求。 This is standard Java EE Servlet configuration; 这是标准的Java EE Servlet配置。 the following example shows such a DispatcherServlet declaration and mapping: 以下示例显示了这样的DispatcherServlet声明和映射:

<web-app>
<servlet>
    <servlet-name>example</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>example</servlet-name>
    <url-pattern>/example/*</url-pattern>
</servlet-mapping>
</web-app>

In the preceding example, all requests starting with /example will be handled by the DispatcherServlet instance named example. 在前面的示例中,所有以/ example开头的请求都将由名为example的DispatcherServlet实例处理。

从您的URI中删除HelloWorld,然后尝试通过/ welcome / hello访问

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM