添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
 <bean id="viewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
          <property name="prefix" value="/WEB-INF/" />  
            <property name="suffix" value=".jsp" />  
     </bean>

controller class

  @RequestMapping(value="/admissionForm.html", method = RequestMethod.GET)
        public ModelAndView getAdmissionForm() {
            ModelAndView model = new ModelAndView("AdmissionForm");
            return model;
        @RequestMapping(value="/admissionForm.jsp", method = RequestMethod.GET)
        public ModelAndView getAdmissionForm2() {
            ModelAndView model = new ModelAndView("AdmissionForm");
            return model;
        @RequestMapping(value="/admissionForm", method = RequestMethod.GET)
        public ModelAndView getAdmissionForm3() {
            ModelAndView model = new ModelAndView("AdmissionForm");
            return model;

web.xml

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

whenever i am accessing the url through /admissionForm.html and /admissionForm i am getting response in webpage but when i access through /admissionForm.jsp i am getting 404 page not found ,my question is what's the reason for this and what i could do to make this work?

First, I am not sure if its for example or your real code but it the mehods are the same you can write

@RequestMapping(value={"/admissionForm","/admissionForm.htm","/admissionForm.html"}, method = RequestMethod.GET)

For your issue, you can try to change your web.xml to

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

so it will recognize the jsp extension

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.25.35491