我在所有页面都有一个公共标题,除了一些页面右侧标题有一些选项。例如,我标题的右侧将有如下选项:Block,Compose,Edit取决于页面。是否可以从tiles-config.xml设置此 headerShowIcons ,然后在rhsHeader.jsp中使用它。
有什么方法可以将一些值从tiles-config.xml传递给rhsHeader.jsp,并根据该值我想显示该选项(即阻止,编辑或删除)
示例:如果我想向用户显示Compose选项,我只需从tiles-config.xml传递值(即headerShowIcons ='撰写')并在JSP中使用它。如果我想显示Block我会传递headerShowIcons =' block' rhsHeader.jsp将读取它以显示Block选项。我希望这会更清楚
瓦片-config.xml中
<definition name="*/*/*/*/*/index" template="/{1}/{2}/xyz/{4}/layouts/layout.jsp">
<put-attribute name="lhsHeader" value="/{1}/{2}/xyz/s/headerWithBack.jsp" />
<put-attribute name="rhsHeader" value="/{1}/{2}/xyz/s/rhsHeader.jsp"/>
<put-attribute name="body" value="/{1}/{2}/xyz/s/myProfile.jsp" />
</definition>
layout.jsp
<!-- What should I add here to meet the requirement -->
<body>
<header>
<div>
<tiles:insertAttribute name="header"/>
<tiles:insertAttribute name="rhsHeader"/>
</div>
</header>
<div>
<tiles:insertAttribute name="body"/>
</div>
</body>
rhsHeader.jsp 是这样的:
<tiles:useAttribute name="headerShowIcons" />
<div class="RHS">
<ul>
<!-- I want to show the options (like- Block,Delete,etc) which will be passed from tiles-config.xml to rhsHeader.jsp (which here I have written it as headerShowIcons )-->
<c:choose>
<c:when test="${headerShowIcons eq 'refine'}">
<li><a href="#" class="refine">Refine</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'block'}">
<li><a href="#" class="block">Block</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'edit'}">
<li><a href="javaScript:void(0);" class="edit">Edit</a></li>
</c:when>
<c:when test="${headerShowIcons eq 'delete'}">
<li><a href="javaScript:void(0);" class="delete">Delete</a></li>
</c:when>
<c:otherwise>
<p>test</p>
</c:otherwise>
</c:choose>
</ul>
答案 0 :(得分:1)
我终于找到了做到这一点的解决方案,我相信这对有这种要求的人有帮助:
我们必须使用
headerLayout.jsp 中的
<tiles:useAttribute name="whatToShow"/>
<header>
<div>
<tiles:insertAttribute name="lhsHeader" />
<tiles:insertAttribute name="rhsHeader">
<tiles:putAttribute name="whatToShow">${whatToShow}</tiles:putAttribute>
</tiles:insertAttribute>
</div>
</header>
<div>
<tiles:insertAttribute name="body"/>
</div>
在 tiles-config.jsp
中 <definition name="Header.*" template="/{1}/layouts/headerLayout.jsp">
<put-attribute name="lhsHeader" value="/s/headerWithBack.jsp"/>
<put-attribute name="rhsHeader" value="/s/rhsHeader.jsp"/>
<put-attribute name="body" value=""/>
<put-attribute name="whatToShow" value="block" type="string"/>
</definition>
<!-- inside the definition under whatToShow, I just write whatever value(block,edit,delete,etc) I want to pass to the rhsHeader.jsp -->
rhsHeader.jsp 中的
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<tiles:useAttribute name="whatToShow"/>
<div class="RHS">
<ul>
<c:choose>
<c:when test="${whatToShow eq 'refine'}">
<li><a href="#" class="refine">Refine</a></li>
</c:when>
<c:when test="${whatToShow == 'block'}">
<li><a href="#" class="block">Block</a></li>
</c:when>
<c:when test="${whatToShow eq 'edit'}">
<li><a href="javaScript:void(0);" class="edit">Edit</a></li>
</c:when>
<c:when test="${whatToShow eq 'delete'}">
<li><a href="javaScript:void(0);" class="delete">Delete</a></li>
</c:when>
<c:otherwise>
<p></p>
</c:otherwise>
</c:choose>
</ul>
</div>
PS:我使用了whatToShow而不是headerShowIcons
答案 1 :(得分:0)
我会选择不同的方式,但如果它是你想要的,请参阅下面的
<强>瓦片-config.xml中强>
#include "common.h"
#include <vector>
// Global variable: list of function pointers in host memory
std::vector<fptr_t> vec_fList;
// Add function to functions list
void addFunc(fptr_t f) {vec_fList.push_back(f);}
// Upload the functions in the std::vector<fptr_t> to GPU memory
// Copies CPU-side pointers to constant_fList, therefore crashes on kernel call
void UploadVector() {
fptr_t* h_vpointer = vec_fList.data();
gpuErrchk( cudaMemcpyToSymbol(constant_fList, h_vpointer, vec_fList.size() * sizeof(fptr_t)) );
}
int main() {
addFunc(Add);
addFunc(Subtract);
addFunc(Multiply);
int a = 12, b = 15;
UploadVector();
kernel<<<1,3>>>(a, b); // Wrong to call a host-side function pointer from a kernel
gpuErrchk(cudaGetLastError());
gpuErrchk(cudaDeviceSynchronize());
return 0;
}
<强>针对home.jsp 强>
f(a,b)
如果您希望可以将其移动到layout.jsp并相应地显示您的标题