developer tip

URI [/WEB-INF/pages/apiForm.jsp] [duplicate]가있는 HTTP 요청에 대한 매핑이 없습니다.

optionbox 2020. 8. 31. 07:41
반응형

URI [/WEB-INF/pages/apiForm.jsp] [duplicate]가있는 HTTP 요청에 대한 매핑이 없습니다.


내 핸들러가 internalresourceview 'apiForm'으로 전달하지만 오류 404 RequestURI = / WEB-INF / pages / apiForm.jsp가 발생합니다. / WEB-INF / pages /에있는 apiForm.jsp를 확신합니다.

13 : 45 : 02,034 DEBUG [org.springframework.web.servlet.view.JstlView]-InternalResourceView 'apiForm'의 리소스 [/WEB-INF/pages/apiForm.jsp]로 전달
13 : 45 : 02,035 DEBUG [org.springframework .web.servlet.DispatcherServlet]-이름이 'testapp2'인 DispatcherServlet이 [/WEB-INF/pages/apiForm.jsp]의 Last-Modified 값을 결정합니다.
13 : 45 : 02,038 DEBUG [org.springframework.web.servlet.DispatcherServlet]- getLastModified
13 : 45 : 02,038 DEBUG [org.springframework.web.servlet.DispatcherServlet] -DispatcherServlet 이름이 'testapp2'인 [/WEB-INF/pages/apiForm.jsp]에 대한 요청 처리 요청
13 : 45 : 02,038WARN [org.springframework.web.servlet.PageNotFound]-이름이 'testapp2'인 DispatcherServlet에서 URI [/WEB-INF/pages/apiForm.jsp]가있는 HTTP 요청에 대한 매핑이 없습니다
. 13 : 45 : 02,045 DEBUG [org.springframework .web.servlet.DispatcherServlet]-성공적으로 요청 완료
13 : 45 : 02,048 DEBUG [org.springframework.web.servlet.DispatcherServlet]-성공적으로 요청 완료

이것이 내 dispatcher.xml의 모습입니다 ..

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>

DispatcherServlet이 apiForm.jsp에 대한 요청을 처리하려고 시도하는 것처럼 보입니다. 이는 web.xml 서블릿 매핑이 해당 공간에 대한 요청을 DispatcherServlet으로 전달하고 있음을 나타냅니다.

당신은 이와 같은 것을 가질 수 있습니까?

<servlet-mapping>
  <servlet>dispatcher</servlet>
  <url-pattern>/*</url-pattern>
</servlet-mapping>

다른 확장자 (예 : .do)로 컨트롤러를 호출하고 이에 맞게 servlet-mapping을 업데이트하십시오.

 <servlet-mapping>
  <servlet>dispatcher</servlet>
  <url-pattern>*.do</url-pattern>
</servlet-mapping>

예,이 파티에 늦었지만 다른 사람들에게 도움이 될 수 있습니다.

서블릿 컨테이너는 일치하는 가장 긴 경로를 기반으로 매핑을 선택합니다. 따라서이 매핑을 JSP에 넣을 수 있으며 / * 매핑을 통해 선택됩니다.

<servlet-mapping>
  <servlet-name>jsp</servlet-name>
  <url-pattern>/WEB-INF/pages/*</url-pattern>
 </servlet-mapping>

실제로 Tomcat의 경우 jsp가 기본적으로 존재하는 서블릿이기 때문에 필요한 전부입니다. 다른 컨테이너의 경우 JSP 서블릿의 이름을 찾거나 다음과 같은 서블릿 정의를 추가해야합니다.

<servlet>
  <servlet-name>jsp</servlet-name>
  <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
</servlet>

<mvc:default-servlet-handler />DispatcherServlet 구성에 추가 하기 만하면 완료됩니다!


당신은 얻을 것이다 No mapping found for HTTP request with URI오류

잘못된 패키지를 스캔 한 경우

예를 들어 컨트롤러가 my.package.abc에 있지만 실수로

<context:component-scan base-package="my.package.efg*" />

또는

@ComponentScan("my.package.efg*")

which in the sense, your controller doesn't get scanned into the web application context, when request comes in not just url, but the entire class is not found!


Solution that helped me is: do not map DispatcherServlet to /*, map it to /. Final config is then:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        ...
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

I think I read the entire internet to figure out how to get sitemesh to handle my html paths without extension + API paths without extension. I was wrapped up in a straight jacket figuring this out, every turn seemed to break something else. Then I finally came upon this post.

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>/WEB-INF/views/*</url-pattern>
 </servlet-mapping>

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>/WEB-INF/decorators/*</url-pattern>
</servlet-mapping>

Enter this in your dispatcher-servlet.xml

<mvc:default-servlet-handler/>

Simple check can be made. I am currently using Spring MVC architecture along with hibernate. I had missed writing @Controller annotations just above class name. This was causing the problem for me.

@Controller
public class MyClass{
    ...
}

Hope this simple check solves your problem.


With Spring 3.1 and Tomcat 7 I got next error:

org.springframework.web.servlet.DispatcherServlet noHandlerFound No mapping found for HTTP request with URI [/baremvc/] in DispatcherServlet with name 'appServlet'

And I needed to add to web.xml next configuration:

<welcome-file-list>
    <welcome-file/>
</welcome-file-list>

And the application worked!


I had the same problem, Of course there was a little difference. The story was that when I was removing the below line:

<mvc:resources mapping="/resources/**" location="classpath:/resources/" />

Everything was OK but in presence of that line the same error raise.

After some trial and error I found I have to add the below line to my spring application context file:

<mvc:annotation-driven />

Hope it helps!


This could also happen when you're app doesn't actually compile, yet it's still launched in Tomcat. When I saw this happen, it wasn't compiling because the project had a "project specific" JDK specified, and the code was checked out on a machine that didn't have that specific JDK. Eclipse defaulted to a JRE instead, not a JDK, and then the app wasn't compiled.

To fix it in our specific case, we just turned off "Project Specific Settings" here:

"Project | Properties | Java Compiler"

Here's more detailed info on how to do this: https://stackoverflow.com/a/2540730/26510


Same answer as Brad Parks... more text though

I had the exact same problem and tried the above solutions along with many others, all with negative results. I even started out with a new, fresh Dev env and simply installed a spring-mvc-template and tried to run it directly after install (should work, but failed for me)

For me the problem was that I was using jdk1.6 in my project, but my selected execution environment in eclipse was jdk1.7. The solution was to change the project specific execution environment settings so that this project is set to jdk1.6. Right click project --> Properties --> Java Compiler --> Check "Enable project specific settings" if it's not already checked --> select the appropriate jdk (or add if it's not installed).

I hope this can help someone and save that persons time, because I have spent the last few days looking for the answer on every corner of the Internet. I accidently stumbled upon it myself when I started to get desperate and look for the solution in areas where it (according to my brain) was less likely to be found. =)

My 2 cents. Thanks!

Edit1: Use project specific settings

Edit2: Just realized Brad Parks already answered this in this very thread. Well, at least I got the "Editor"-badge out of this one =D


Unfortunately, this is a rather broad class error message. Yet another thing which could be going wrong is if you are missing some classes/jars. For example, if you are missing the spring-expression jar file, the dispatch-servlet is not going to be able to locate your controller no matter how hard you try and how correct everything else is configured.


I have encountered this problem in Eclipse Luna EE. My solution was simply restart eclipse and it magically started loading servlet properly.


What you need is to have a controller that responds to the url first which then renders your jsp. See this link for a solution.


"/openStudentPage" is the page that i want to open first, i did :

 @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(Model model) {
     return "redirect:/openStudentPage";
    }

@RequestMapping(value = "/openStudentPage", method = RequestMethod.GET)
public String listStudents(Model model) {
    model.addAttribute("student", new Student());
    model.addAttribute("listStudents", this.StudentService.listStudents());
    return "index";
}

change the your servlet name dispatcher to any other name .because dispatcher is predefined name for spring3,spring4 versions.

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

참고URL : https://stackoverflow.com/questions/1266303/no-mapping-found-for-http-request-with-uri-web-inf-pages-apiform-jsp

반응형