java.lang.ClassNotFoundException: org.springframework.expression.ExpressionParser

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22273056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 14:39:55  来源:igfitidea点击:

java.lang.ClassNotFoundException: org.springframework.expression.ExpressionParser

javaspring-mvc

提问by JDGuide

I am total new to Spring, and do not know where I am making a mistake. I am using spring 4.0.2 jars with eclipse and tomcat.

我对 Spring 完全陌生,不知道我在哪里犯了错误。我在 Eclipse 和 tomcat 中使用 spring 4.0.2 jars。

All Jar files:

所有 Jar 文件:

spring-aop-4.0.2.RELEASE
spring-beans-4.0.2.RELEASE
spring-context-4.0.2.RELEASE
spring-context-support-4.0.2.RELEASE
spring-core-4.0.2.RELEASE
spring-jdbc-4.0.2.RELEASE
spring-jms-4.0.2.RELEASE
spring-orm-4.0.2.RELEASE
spring-test-4.0.2.RELEASE
spring-tx-4.0.2.RELEASE
spring-web-4.0.2.RELEASE
spring-webmvc-4.0.2.RELEASE
commons-logging-1.1.3

index.jsp:

索引.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
  <h2>Spring Home Page</h2>

  <form name="frmTravel" method="get" action="/SimpleSpringApp/travell">
    Travel Name : <input type="text" name="tvlName" />
    <input type="submit" value="Submit"/>
  </form>
</body>
</html>

success.jsp:

成功.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Travel Success</title>
</head>
<body>
    <h2>Success Page</h2>
    <h3>Here need to show the message</h3>
</body>
</html>

Web.xml:

网页.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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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>SimpleSpringApp</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>


  <!-- ddf -->
  <servlet>
      <servlet-name>Travel</servlet-name>
      <servlet-class>
         org.springframework.web.servlet.DispatcherServlet
      </servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>

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

</web-app>

Travel-servlet.xml:

旅行-servlet.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">

   <context:component-scan base-package="com.manoj.springprac" />

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property name="suffix" value=".jsp" />
   </bean>

</beans>

Travel.java:

旅行.java:

/**
 * 
 */
package com.manoj.springprac;

/**
 * @author Manoj
 *
 */
public class Travel {


    private String tvlName;

    public String getTvlName() {
        return tvlName;
    }

    public void setTvlName(String tvlName) {
        this.tvlName = tvlName;
    }


}

TravelController.java:

TravelController.java:

package com.manoj.springprac;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class TravelController  {

    @RequestMapping(value = "/travell", method = RequestMethod.GET)
    public String printHello(ModelMap model) {
          model.addAttribute("message", "Hello Spring MVC Framework!");
          return "success";
       }

    //Here I want to save the data to database also

}

I really do not know where I am missing the configuration, and where the SimpleFormControllerin spring 4.0.x.

我真的不知道我在哪里缺少配置,以及SimpleFormControllerspring 4.0.x 中的哪里。

Any suggestions will be helpful.

任何建议都会有所帮助。

回答by JDGuide

I have missed out the spring-expression jar file. I have added that and its working fine.

我错过了 spring-expression jar 文件。我已经添加了它并且它工作正常。

You can download from http://mvnrepository.com/artifact/org.springframework/spring-expression/4.0.2.RELEASE

您可以从http://mvnrepository.com/artifact/org.springframework/spring-expression/4.0.2.RELEASE下载

回答by Vikash

I was Facing the Same error in Console while working with SpringBoot 2.0.0 Release. I changed the version of Spring-Boot-Starter-Parent to 1.5.10Release. It worked fine for me.

在使用 SpringBoot 2.0.0 Release 时,我在控制台中遇到了相同的错误。我将 Spring-Boot-Starter-Parent 的版本改为 1.5.10Release。它对我来说很好。