http error 404 resource not found in spring mvc [duplicate]










-1
















This question already has an answer here:



  • Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”?

    6 answers



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"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>ValidationForm</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> spring-dispatcher-servlet.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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name> ValidationForm</display-name> <servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
</web-app>


index.jsp



 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/wel" method="post">
name:<input type="text" name="name" placeholder="UserName">
<br> password:<input type="password" name="pass" placeholder="Password">
<br>
<input type="submit" value="login">
</form>
</body>
</html>


HomeController.java



 package jbr.springmvc.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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller public class HomeController
@RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
public ModelAndView hello(HttpServletRequest req,HttpServletResponse res)

String name=req.getParameter("name");
String pass=req.getParameter("pass");

if(name.equals("mohit")&&pass.equals("admin"))
String messege="Welcome"+name;

return new ModelAndView("welcomepage","message",messege);

else
return new ModelAndView("errorpage","message","Authantication Failed");




in this this will show error 404 resource not found i really dont know what happened into this becoz i am in new on spring. please help guys.
thanks in advance.










share|improve this question















marked as duplicate by Raedwald, BalusC java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 10:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • You have to at least format it properly first, and provide project structure

    – nguyentaijs
    Nov 14 '18 at 8:10












  • Have you a welcomepage.jsp?

    – achAmháin
    Nov 14 '18 at 8:25











  • yeh i have welcomepage and errorpage as well

    – Mohit Aggarwal
    Nov 14 '18 at 8:55















-1
















This question already has an answer here:



  • Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”?

    6 answers



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"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>ValidationForm</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> spring-dispatcher-servlet.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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name> ValidationForm</display-name> <servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
</web-app>


index.jsp



 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/wel" method="post">
name:<input type="text" name="name" placeholder="UserName">
<br> password:<input type="password" name="pass" placeholder="Password">
<br>
<input type="submit" value="login">
</form>
</body>
</html>


HomeController.java



 package jbr.springmvc.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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller public class HomeController
@RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
public ModelAndView hello(HttpServletRequest req,HttpServletResponse res)

String name=req.getParameter("name");
String pass=req.getParameter("pass");

if(name.equals("mohit")&&pass.equals("admin"))
String messege="Welcome"+name;

return new ModelAndView("welcomepage","message",messege);

else
return new ModelAndView("errorpage","message","Authantication Failed");




in this this will show error 404 resource not found i really dont know what happened into this becoz i am in new on spring. please help guys.
thanks in advance.










share|improve this question















marked as duplicate by Raedwald, BalusC java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 10:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • You have to at least format it properly first, and provide project structure

    – nguyentaijs
    Nov 14 '18 at 8:10












  • Have you a welcomepage.jsp?

    – achAmháin
    Nov 14 '18 at 8:25











  • yeh i have welcomepage and errorpage as well

    – Mohit Aggarwal
    Nov 14 '18 at 8:55













-1












-1








-1









This question already has an answer here:



  • Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”?

    6 answers



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"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>ValidationForm</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> spring-dispatcher-servlet.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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name> ValidationForm</display-name> <servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
</web-app>


index.jsp



 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/wel" method="post">
name:<input type="text" name="name" placeholder="UserName">
<br> password:<input type="password" name="pass" placeholder="Password">
<br>
<input type="submit" value="login">
</form>
</body>
</html>


HomeController.java



 package jbr.springmvc.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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller public class HomeController
@RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
public ModelAndView hello(HttpServletRequest req,HttpServletResponse res)

String name=req.getParameter("name");
String pass=req.getParameter("pass");

if(name.equals("mohit")&&pass.equals("admin"))
String messege="Welcome"+name;

return new ModelAndView("welcomepage","message",messege);

else
return new ModelAndView("errorpage","message","Authantication Failed");




in this this will show error 404 resource not found i really dont know what happened into this becoz i am in new on spring. please help guys.
thanks in advance.










share|improve this question

















This question already has an answer here:



  • Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”?

    6 answers



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"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>ValidationForm</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> spring-dispatcher-servlet.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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name> ValidationForm</display-name> <servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
</web-app>


index.jsp



 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/wel" method="post">
name:<input type="text" name="name" placeholder="UserName">
<br> password:<input type="password" name="pass" placeholder="Password">
<br>
<input type="submit" value="login">
</form>
</body>
</html>


HomeController.java



 package jbr.springmvc.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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller public class HomeController
@RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
public ModelAndView hello(HttpServletRequest req,HttpServletResponse res)

String name=req.getParameter("name");
String pass=req.getParameter("pass");

if(name.equals("mohit")&&pass.equals("admin"))
String messege="Welcome"+name;

return new ModelAndView("welcomepage","message",messege);

else
return new ModelAndView("errorpage","message","Authantication Failed");




in this this will show error 404 resource not found i really dont know what happened into this becoz i am in new on spring. please help guys.
thanks in advance.





This question already has an answer here:



  • Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”?

    6 answers







java xml spring spring-mvc servlets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:11









georges van

2,29622438




2,29622438










asked Nov 14 '18 at 7:56









Mohit AggarwalMohit Aggarwal

13




13




marked as duplicate by Raedwald, BalusC java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 10:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Raedwald, BalusC java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 10:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • You have to at least format it properly first, and provide project structure

    – nguyentaijs
    Nov 14 '18 at 8:10












  • Have you a welcomepage.jsp?

    – achAmháin
    Nov 14 '18 at 8:25











  • yeh i have welcomepage and errorpage as well

    – Mohit Aggarwal
    Nov 14 '18 at 8:55

















  • You have to at least format it properly first, and provide project structure

    – nguyentaijs
    Nov 14 '18 at 8:10












  • Have you a welcomepage.jsp?

    – achAmháin
    Nov 14 '18 at 8:25











  • yeh i have welcomepage and errorpage as well

    – Mohit Aggarwal
    Nov 14 '18 at 8:55
















You have to at least format it properly first, and provide project structure

– nguyentaijs
Nov 14 '18 at 8:10






You have to at least format it properly first, and provide project structure

– nguyentaijs
Nov 14 '18 at 8:10














Have you a welcomepage.jsp?

– achAmháin
Nov 14 '18 at 8:25





Have you a welcomepage.jsp?

– achAmháin
Nov 14 '18 at 8:25













yeh i have welcomepage and errorpage as well

– Mohit Aggarwal
Nov 14 '18 at 8:55





yeh i have welcomepage and errorpage as well

– Mohit Aggarwal
Nov 14 '18 at 8:55












2 Answers
2






active

oldest

votes


















-1














As i checked this code is working:



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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ValidationForm</display-name>


<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>

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




Spring-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"
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">

<annotation-driven />
<context:component-scan base-package="com.demo.spring" />
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>




HomeController:



package com.demo.spring.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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HomeController
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView welcome()
return new ModelAndView("welcome");


@RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
public ModelAndView hello(HttpServletRequest req, HttpServletResponse res)

String name = req.getParameter("name");
String pass = req.getParameter("pass");

if (name.equals("mohit") && pass.equals("admin"))
String messege = "Welcome" + name;

return new ModelAndView("welcome", "message", messege);
else
return new ModelAndView("errorpage", "message", "Authantication Failed");





Try to use it






share|improve this answer






























    -1














    You need to configure your view resolver.

    1. first create spring-dispatcher.xml file.
    2. Add view resolver configuration in your xml file.
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
    3. place jsp file in views folder under webapp--> WEB-INF.
    4. Now view resolver will find jsp at this path " /WEB-INF/views/yoursjspname.jsp ".





    share|improve this answer





























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      -1














      As i checked this code is working:



      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"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      id="WebApp_ID" version="3.0">
      <display-name>ValidationForm</display-name>


      <servlet>
      <servlet-name>spring-dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring-servlet.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>

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




      Spring-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"
      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">

      <annotation-driven />
      <context:component-scan base-package="com.demo.spring" />
      <beans:bean
      class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <beans:property name="prefix" value="/WEB-INF/views/" />
      <beans:property name="suffix" value=".jsp" />
      </beans:bean>




      HomeController:



      package com.demo.spring.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.bind.annotation.RequestMethod;
      import org.springframework.web.servlet.ModelAndView;

      @Controller
      public class HomeController
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public ModelAndView welcome()
      return new ModelAndView("welcome");


      @RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
      public ModelAndView hello(HttpServletRequest req, HttpServletResponse res)

      String name = req.getParameter("name");
      String pass = req.getParameter("pass");

      if (name.equals("mohit") && pass.equals("admin"))
      String messege = "Welcome" + name;

      return new ModelAndView("welcome", "message", messege);
      else
      return new ModelAndView("errorpage", "message", "Authantication Failed");





      Try to use it






      share|improve this answer



























        -1














        As i checked this code is working:



        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"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="WebApp_ID" version="3.0">
        <display-name>ValidationForm</display-name>


        <servlet>
        <servlet-name>spring-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>

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




        Spring-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"
        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">

        <annotation-driven />
        <context:component-scan base-package="com.demo.spring" />
        <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
        </beans:bean>




        HomeController:



        package com.demo.spring.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.bind.annotation.RequestMethod;
        import org.springframework.web.servlet.ModelAndView;

        @Controller
        public class HomeController
        @RequestMapping(value = "/", method = RequestMethod.GET)
        public ModelAndView welcome()
        return new ModelAndView("welcome");


        @RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
        public ModelAndView hello(HttpServletRequest req, HttpServletResponse res)

        String name = req.getParameter("name");
        String pass = req.getParameter("pass");

        if (name.equals("mohit") && pass.equals("admin"))
        String messege = "Welcome" + name;

        return new ModelAndView("welcome", "message", messege);
        else
        return new ModelAndView("errorpage", "message", "Authantication Failed");





        Try to use it






        share|improve this answer

























          -1












          -1








          -1







          As i checked this code is working:



          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"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          id="WebApp_ID" version="3.0">
          <display-name>ValidationForm</display-name>


          <servlet>
          <servlet-name>spring-dispatcher</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring-servlet.xml</param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>

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




          Spring-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"
          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">

          <annotation-driven />
          <context:component-scan base-package="com.demo.spring" />
          <beans:bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <beans:property name="prefix" value="/WEB-INF/views/" />
          <beans:property name="suffix" value=".jsp" />
          </beans:bean>




          HomeController:



          package com.demo.spring.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.bind.annotation.RequestMethod;
          import org.springframework.web.servlet.ModelAndView;

          @Controller
          public class HomeController
          @RequestMapping(value = "/", method = RequestMethod.GET)
          public ModelAndView welcome()
          return new ModelAndView("welcome");


          @RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
          public ModelAndView hello(HttpServletRequest req, HttpServletResponse res)

          String name = req.getParameter("name");
          String pass = req.getParameter("pass");

          if (name.equals("mohit") && pass.equals("admin"))
          String messege = "Welcome" + name;

          return new ModelAndView("welcome", "message", messege);
          else
          return new ModelAndView("errorpage", "message", "Authantication Failed");





          Try to use it






          share|improve this answer













          As i checked this code is working:



          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"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          id="WebApp_ID" version="3.0">
          <display-name>ValidationForm</display-name>


          <servlet>
          <servlet-name>spring-dispatcher</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring-servlet.xml</param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>

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




          Spring-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"
          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">

          <annotation-driven />
          <context:component-scan base-package="com.demo.spring" />
          <beans:bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <beans:property name="prefix" value="/WEB-INF/views/" />
          <beans:property name="suffix" value=".jsp" />
          </beans:bean>




          HomeController:



          package com.demo.spring.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.bind.annotation.RequestMethod;
          import org.springframework.web.servlet.ModelAndView;

          @Controller
          public class HomeController
          @RequestMapping(value = "/", method = RequestMethod.GET)
          public ModelAndView welcome()
          return new ModelAndView("welcome");


          @RequestMapping(value = "demo1/wel", method = RequestMethod.POST)
          public ModelAndView hello(HttpServletRequest req, HttpServletResponse res)

          String name = req.getParameter("name");
          String pass = req.getParameter("pass");

          if (name.equals("mohit") && pass.equals("admin"))
          String messege = "Welcome" + name;

          return new ModelAndView("welcome", "message", messege);
          else
          return new ModelAndView("errorpage", "message", "Authantication Failed");





          Try to use it







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 9:15









          Ravi DeveloperRavi Developer

          7819




          7819























              -1














              You need to configure your view resolver.

              1. first create spring-dispatcher.xml file.
              2. Add view resolver configuration in your xml file.
              <beans:property name="prefix" value="/WEB-INF/views/" />
              <beans:property name="suffix" value=".jsp" />
              3. place jsp file in views folder under webapp--> WEB-INF.
              4. Now view resolver will find jsp at this path " /WEB-INF/views/yoursjspname.jsp ".





              share|improve this answer



























                -1














                You need to configure your view resolver.

                1. first create spring-dispatcher.xml file.
                2. Add view resolver configuration in your xml file.
                <beans:property name="prefix" value="/WEB-INF/views/" />
                <beans:property name="suffix" value=".jsp" />
                3. place jsp file in views folder under webapp--> WEB-INF.
                4. Now view resolver will find jsp at this path " /WEB-INF/views/yoursjspname.jsp ".





                share|improve this answer

























                  -1












                  -1








                  -1







                  You need to configure your view resolver.

                  1. first create spring-dispatcher.xml file.
                  2. Add view resolver configuration in your xml file.
                  <beans:property name="prefix" value="/WEB-INF/views/" />
                  <beans:property name="suffix" value=".jsp" />
                  3. place jsp file in views folder under webapp--> WEB-INF.
                  4. Now view resolver will find jsp at this path " /WEB-INF/views/yoursjspname.jsp ".





                  share|improve this answer













                  You need to configure your view resolver.

                  1. first create spring-dispatcher.xml file.
                  2. Add view resolver configuration in your xml file.
                  <beans:property name="prefix" value="/WEB-INF/views/" />
                  <beans:property name="suffix" value=".jsp" />
                  3. place jsp file in views folder under webapp--> WEB-INF.
                  4. Now view resolver will find jsp at this path " /WEB-INF/views/yoursjspname.jsp ".






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 9:20









                  Dildeep SinghDildeep Singh

                  447




                  447













                      Popular posts from this blog

                      How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                      Syphilis

                      Darth Vader #20