根据标记文件中的TLD或属性指令,属性项不接受任何表达式 [英] According to TLD or attribute directive in tag file, attribute items does not accept any expressions

查看:2247
本文介绍了根据标记文件中的TLD或属性指令,属性项不接受任何表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我需要在HTML页面中显示电影的详细信息。我必须严格遵循MVC,虽然我没有使用任何框架,如Spring或Struts。我也不允许使用scriptlet,但使用JSTL和表达式语言。我通常从数据库中检索数据,然后将其设置为bean,然后创建这些bean的列表并将其传递给JSP,然后打印这些详细信息。但是如果我不被允许使用JSP,我将如何实现它。如果我使用servlet检索这些数据并将其设置为bean然后再将其设置为列表并通过请求调度程序传递,那么我将如何从HTML页面的列表中获取每个bean?

I have a project where I need to display details of movies in an HTML page. I must strictly follow MVC although I am not using any framework like Spring or Struts. I am also not allowed to use scriptlets, but use JSTL and expression language. I usually retrieve data from database and then set it to a bean and then make a list of those bean and pass it to JSP and then print those details. But how would I achieve it if I am not allowed to use JSP. If I use servlet to retrieve those data and set it to a bean and then to a list and pass it through request dispatcher, how am I going to get each bean from the list in the HTML page?

我无法让这个JSTL工作。我使用的是Netbeans 7.0和Apache Tomcat 7.

I could not get this JSTL working. I am using Netbeans 7.0 and Apache Tomcat 7.

 <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>DVD Guru</title>
        <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    </head>
    <body>   
     <div id="wrapper">     
        <c:set var="testing" value="blah"/>
                <c:out value="${testing}"/>
        </div>      
    </body>
</html>

我收到以下错误


根据标签文件中的TLD或属性指令,属性项不接受任何表达式

According to TLD or attribute directive in tag file, attribute items does not accept any expressions

我导入了JSTL 1.1来自项目属性的库。
是否应该做其他事情?

I have imported JSTL 1.1 library from project properties. Should anything else should be done?

推荐答案

你必须使用 JSP JSTL - 只是一组自定义标签,不能单独使用。以及表达语言。如果您没有使用任何MVC框架,那么您需要自己完成一些工作。请看下面的设计模式(如果你还没有):

You must use JSP, JSTL - is just set of custom tags and can not be used separately. As well as Expression Language. If you are not using any MVC frameworks, then you need to do some of their work by yourself. Please take a look (if you haven't yet) at following design patterns:


  1. Front Controller 命令用于简单应用程序

  2. 前端控制器查看助手了解更复杂的应用程序

  1. Front Controller, Command for simple application
  2. Front Controller, View Helper for more complex application

UPD

要解决EL问题,请尝试将JSP中的JSTL uri更正为:

To resolve issue with EL, please try to correct JSTL uri in your JSP to:

 <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>

这篇关于根据标记文件中的TLD或属性指令,属性项不接受任何表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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