Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在标记文件JSP中传递变量_Java_Jsp_Tagfile - Fatal编程技术网

Java 在标记文件JSP中传递变量

Java 在标记文件JSP中传递变量,java,jsp,tagfile,Java,Jsp,Tagfile,我想在标记文件中传递一个变量。我的代码在这里: layout.tag <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@tag description="My layout" pageEncoding="UTF-8"%> <%@attribute name="title" type="java.lang.String" required="true" %> <!DOC

我想在标记文件中传递一个变量。我的代码在这里:

layout.tag

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@tag description="My layout" pageEncoding="UTF-8"%>
<%@attribute name="title" type="java.lang.String" required="true" %>  
<!DOCTYPE html>
<html>
<head>
    <title>My site | <c:out value="${title}" /></title>
</head>
<body>
</body>
</html>

我的网站|
index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="mySite" tagdir="/WEB-INF/tags" %>
<mySite:layout title="home">
</mySite:layout>`

`
但是
1。)在.tag文件中添加
,根据您的方便更改名称

2.
像这样传递值

这对我有用。您使用的是什么容器,它的版本是什么?@SotiriosDelimanolis我使用的是maven和Java1.7。我使用
并且它可以工作……您使用的是什么Servlet容器?雄猫?什么版本?我正在使用Tomcat v7.0检查您的安装是否包含EL库。