JSP表达式语言错误 [英] JSP Expression Language Error

查看:57
本文介绍了JSP表达式语言错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个动态Web模块项目usig STS和Spring MVC.问题是我已经在模型中添加了一个字符串,但是无法使用EL在JSP页面上显示它.

I have created a dynamic web module project usig STS and Spring MVC. The problem is I have add a string into a Model but it cannot be display on the JSP page using EL.

我可以知道这有什么问题吗?

May I know what wrong with it?

以下是详细信息: JSP页面

Below is the details: JSP Page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring MVC</title>
</head>
<body>
    Home 
    <br />

    <c:out value="${message}" /> 

</body>
</html>

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" 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" version="3.0">

MVC控制器:

@Controller
public class HomeController {

    public HomeController() {
        super();
    }

    @RequestMapping(value="/home", method=RequestMethod.GET)
    public ModelAndView showHomePage() {

        // View Name - Model Name - Model Data
        return new ModelAndView("home", "message", "Hello Spring MVC");
    }
}

Dispatcher-servlet.xml

Dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- http://www.jpalace.org/docs/tutorials/spring/mvc_10.html -->

    <!-- Context Scan -->
    <context:component-scan base-package="com.peter.controller"/>

    <!-- Handler Mapping -->
    <bean id="handlerMapping" class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    </bean>

    <!-- Handler Adapter - AnnotationMethodHandlerAdapter --> 
    <!-- Invoke Handler Method -->
    <bean id="handlerAdapter" class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    </bean> 

    <!-- Pre/Post Handler Interceptor -->
    <!-- 
    Implement HandlerInterceptor 
    Declare HandlerInterceptor inside DefaultAnnotationHandlerMapping property or 
    globally inside <mvc:interceptors>
    Need configure Filter object inside web.xml 

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="interceptors">
            <list>
                <bean class="pckg.MyInterceptor1"/>
                <bean class="pckg.MyInterceptor2"/>
            </list>
        </property>
    </bean>

    <mvc:interceptors>
        <bean class="pckg.MyInterceptor1"/>
        <bean class="pckg.MyInterceptor2"/>
    </mvc:interceptors>

    -->

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

    <!-- Exception Resolver -->

    <!-- Register Interceptor, Message Resource, Bean validation support, Message conversion and field formatting -->
    <mvc:annotation-driven />

</beans>

我的构建路径中有JSTL.jar.在Java构建路径上找不到关于"c:out"的标记处理程序类(org.apache.taglibs.standard.tag.rt.core.OutTag)的警告消息.

I have JSTL.jar in my build path. There is warning message about the The tag handler class for "c:out" (org.apache.taglibs.standard.tag.rt.core.OutTag) was not found on the Java Build Path

请帮助.

谢谢.

推荐答案

  • 从Maven存储库(http://repo1.maven.org/maven2/javax/servlet/jstl/1.2/)下载jstl-1.2.jar.
  • 确保 该jar文件位于Web应用程序的WEB-INF \ lib文件夹中.

    • Download jstl-1.2.jar from the maven repo (http://repo1.maven.org/maven2/javax/servlet/jstl/1.2/).
    • Ensure that the jar is available in WEB-INF\lib folder of your web application.

      这篇关于JSP表达式语言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆