Getting an error even after adding all jars in user library HTTP Status 404 - Servlet mvc-dispatcher is not available jars already added in user library being used. Tried all sorts not able to resolve Can't post screenshots as i don't have 10 points
Servlet mapping code in web.xml is below:
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet.class</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>*.spring</url-pattern>
</servlet-mapping>
My Jsp is below
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="Login.spring" method = "post">
<input type = "text" name = "userName" id = "userName">
<input type = "password" name = "password" id = "password">
<input type = "submit">
</form>
</body>
</html>
My Controller is below
package com.lnt.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.lnt.services.AuthenticateServices;
@Controller
@RequestMapping("/Login.spring")
public class LoginController {
//@Autowired
AuthenticateServices authenticateService = new AuthenticateServices();
@RequestMapping(method=RequestMethod.POST)
public ModelAndView processCredentials(HttpServletRequest req, HttpServletResponse res)
{
String userName =req.getParameter("userName") ;
String password = req.getParameter("password");
System.out.println("into login controller");
String message = "Invalid credentials";
List<String> userdetails = new ArrayList<String>();
userdetails = authenticateService.verifyUserNameAndPassword(userName, password);
if((userdetails)!=null)
{
message = "welcome" + userName ;
}
return new ModelAndView("results", "message", message) ;
}
}
Here is the stack trace :
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet.class at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(S tandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Your configuration is wrong
<servlet-class>org.springframework.web.servlet.DispatcherServlet.class</servlet-class>
The <servlet-class>
element expects the name of a class. There is no such class called
org.springframework.web.servlet.DispatcherServlet.class
You probably meant
org.springframework.web.servlet.DispatcherServlet
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.