简体   繁体   English

strut 2 s:select 在 jsp 文件中不起作用

[英]strut 2 s:select won't work within a jsp file

Hi I am getting an error where my s:select will work fine in the parent jsp file but when it is within another jsp file that is being called upon by the parent.jsp it doesn't seem to work anymore. Hi I am getting an error where my s:select will work fine in the parent jsp file but when it is within another jsp file that is being called upon by the parent.jsp it doesn't seem to work anymore. I removed everything down to just these two lines and all the extra stuff around the select.我删除了所有内容,只剩下这两行以及 select 周围的所有额外内容。 Any suggestion or advice is greatly appreciated!非常感谢任何建议或建议!

parent.jsp父.jsp

<%@ taglib uri="/struts-tags" prefix="s" %>
<s:select label="some label"
    list="#{'01':'Dev','2':'Manager','03':'Customer'}"
    name="test"
    />    
<s:component template="child.jsp" templateDir="/pub/" theme="folder1" />

child.jsp child.jsp

<%@ taglib uri="/struts-tags" prefix="s" %>
<s:select label="some label"
        list="#{'01':'Dev','2':'Manager','03':'Customer'}"
        name="test"
        />

File structure文件结构

/pub /酒吧

----/folder1 ----/文件夹1

--------parent.jsp <-- dropdown displays appears --------parent.jsp <--出现下拉菜单

--------child.jsp <--- dropdown breaks --------child.jsp <--- 下拉中断

Error message错误信息

Struts Problem Report
Struts has detected an unhandled exception: 
Messages:
Non-normalized name, starts with "/": /pub//simple/select.ftl
File:
freemarker/cache/TemplateCache.java
Line number:
914

From what I understand turns out it seems to be that you need to set the templateDir inside the child.jsp to the path to the template directory that it is within Struts 2 so it can find the code for s:select.据我了解,您似乎需要将 child.jsp 中的 templateDir 设置为 Struts 2 中模板目录的路径,以便它可以找到 s:select 的代码。 This code managed to fix the issue:此代码设法解决了这个问题:

<s:set var="templateDir" value="%{'template'}" scope="page"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM