Struts逻辑问题
为什么下面的代码不起作用? 这个想法是,页面检查自上次刷新页面以来下拉变量是否发生了变化。
<logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:equal name="Result" value = "-1">
<bean:define id="DropDownValue" name="smlMoverDetailForm" property="moverChangeType"
type="java.lang.String" toScope = "session" />
</logic:equal>
<-- when you fisrt access this page from the above are run -->
<bean:define id="NewDropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "sess
<-- this happens everytime the page is refreshed-->
<logic:equal name= DropDownValue value = NewDropDownValue>
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:notEqual name="DropDownValue" value = "NewDropDownValue">
<bean:define id="DropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"
/>
</logic:notEqual>
Why doesn't the code below work? The idea is that the page checks to see if the dropdown variable has changes since you last refreshed the page.
<logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:equal name="Result" value = "-1">
<bean:define id="DropDownValue" name="smlMoverDetailForm" property="moverChangeType"
type="java.lang.String" toScope = "session" />
</logic:equal>
<-- when you fisrt access this page from the above are run -->
<bean:define id="NewDropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "sess
<-- this happens everytime the page is refreshed-->
<logic:equal name= DropDownValue value = NewDropDownValue>
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:notEqual name="DropDownValue" value = "NewDropDownValue">
<bean:define id="DropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"
/>
</logic:notEqual>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您已经意识到,您的 bean:define - 至少在您在这里提出的问题中 - 是有缺陷的?
很可能不是您想要的 - 它甚至不会终止标签。 但这可能是在 StackOverflow 中格式化的...此外,其他答案中也提到了缺少的引号。
错误可能是 value 属性的使用:根据 http ://struts.apache.org/1.2.x/userGuide/struts-logic.html#equal value 是该标签的其他属性指定的变量的常量值,因此
,假设您已经定义了一个名为 NewDropDownValue 的 bean,您可能想要评估
编辑:此外,我不记得当您仅有条件地定义一个 bean 时会发生什么 - 您的 bean 是在逻辑中定义的:equal 块可能会或可能不会被评估。 它可能是合法的并且有明确的结果,我只是不记得了......
You have realized, that your bean:define - at least in your question stated here - is flawed?
is most likely not what you want - it doesn't even terminate the tag. But this may be formatting in StackOverflow... Also, the missing quotes have been mentioned in other answers.
The error may be the use of the value property: According to http://struts.apache.org/1.2.x/userGuide/struts-logic.html#equal value is The constant value to which the variable, specified by other attribute(s) of this tag, will be compared.
Thus, given that you've defined a bean named NewDropDownValue you might want to evaluate
Edit: Additionally I can't remember what happens when you only conditionally define a bean - your bean is defined inside a logic:equal block that might or might not be evaluated. It might be legal and have defined results, I just can't remember...
我不确定这是否是您的问题(请描述它如何不起作用),但上面的内容不是有效的 xml:它需要在属性值周围加上引号。
I'm not sure if this is your problem (describe how it doesn't work please), but the above is not valid xml: it needs quotes around the attribute values.
问题是正如您所描述的,我无法获取逻辑标签来评估定义的 bean 中保存的值。
The problem is as your describe i can't get the logic tags to evaluate the values held in the defined beans.
实际上,我真的不明白你想要什么,但这里有一些伪代码(删除那些危险的尖括号)问题中的代码
这可能是一个错误(你可能想检查一次“等于”,一次检查“does”不等于')或者写得更短更清晰
如果您将一些输出放置在这些逻辑标签内并发布输出和更多的上下文(例如实际的),您的问题可能会得到更好的答案(或者由您自己回答)参数值——什么是“结果”)。 但是,您是通过未注册的帐户发布的,并且已经有一段时间没有被看到了......
Actually, I don't really get what you want, but here's some pseudocode (removing those dangerous pointy brackets) of your code in the question
This might be an error (you might want to check once for 'equals' and once for 'does not equal') or be written shorter and more clear
Your question might get better answers (or be answered by you yourself) if you placed some output inside of those logic tags and post both the output and a bit more of the context (e.g. actual parameter values -- what is 'Result'). But then - you've posted from an unregistered account and have not been seen for some time...
试试这个:
错误更正:
我认为这些更改将使其正确运行。
Try this:
Errors corrected:
I think those changements will make it runs correctly.