ognl

How to use JSTL <c:forEach> with Struts2 <s:url>?

喜夏-厌秋 提交于 2019-12-18 06:57:08
问题 I have this code that actually works: <s:iterator value="breadcrumb.links" var="link"> <s:url action='%{#link.url}' var="url" /> <li> <a href="${url}">${link.name}</a> </li> </s:iterator> How con I do the same thing but with c:foreach instead of s:iterator ? I tried with: <c:forEach items="${breadcrumb.links}" var="link"> <s:url action='${link.url}' var="url" /> <li> <a href="${url}">${link.name}</a> </li> </c:forEach> but I get the error: According to TLD or attribute directive in tag file,

Struts 2 - The usage of %{ } notation

此生再无相见时 提交于 2019-12-18 05:17:20
问题 What is the exact use of %{} notation in Struts 2? Can someone explain with a simple example where the code works when %{} is used and does not works when its not used? 回答1: Used in OGNL to force evaluate the content in brackets as OGNL expression. For example <s:iterator value = "myAnswers" status="stat"> <s:textfield name = "myAnswers[%{#stat.index}].name"/> evaluation of the stat.index should be forced. 来源: https://stackoverflow.com/questions/18491659/struts-2-the-usage-of-notation

Mybatis开发遇到问题汇总

ぃ、小莉子 提交于 2019-12-16 15:24:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1.mybatis 中![CDATA[...]] 在今天使用Mybatis的xml文件中写sql语句时写入了一些特殊字符 如 < > & 等,但解析xml文件的时候会被转义,事实上并不希望它被转义,可以使用<![CDATA[ ]]>. 这是XML语法,在CDATA内部的所有内容都会被解析器忽略. 但是因此 会导致<if test=""></if> <where></where> <choose></choose> <trim></trim>等标签本身功能失效, 所以使用时把带有特殊字符的语句或字符本身放在<![CDATA[ ]]>内即可,即尽量 精确其作用范围. 也就是当你在使用有<if test=""></if> <where></where> <choose></choose> <trim></trim>的标签中使用 < > & 等特殊字符的时候,会出现xml语法错误,需要使用<![CDATA[ ]]>将 < > & 等特殊字符被解析器忽略,正确书写: <select id="findChannelAlarmPage" resultType="DVBSChannelAlarmModel"> select * from dvbs_channel_alarm_tab where 1=1 <if test=

Struts validator of field conditional to another variable on the jsp

[亡魂溺海] 提交于 2019-12-13 08:49:50
问题 I'm using the struts validator for a jsp validation and i want to know how can I define a field validation depending on the value of another field of my jsp. I have a list of elements like this one : <s:select name="varName" label="labelVariable" list="listeVariable" listValue="varValue" listKey="varKey"/> And a textfield like this one : <s:textfield name="varNameText" label="labelText"/> In my validator I want to validate the size of the field 'varNameText' depending on the selected value on

How to update the model from the data entered in the form after submit in Struts 2

纵然是瞬间 提交于 2019-12-13 07:10:45
问题 I have a form in Struts2 with different types of fields. When I enter data into the form and submit it, no data entered are valued and in the ActionSupport class they are null . Below a sample of my problem struts.xml : <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="false" /> <constant name="struts.action.extension"

Struts2: Malformed OGNL expression

倾然丶 夕夏残阳落幕 提交于 2019-12-12 20:00:20
问题 In my JSPs, I'm using a plugin named TagEdit, It has to have an input text field with " name='tag[]' " like below: <s:form theme="simple" action="myActionn" method="post"> <s:textfield theme="simple" name="tag[]" value="" cssClass="tag"/> <sj:submit targets="actionMessageResult"/> </s:form> But when I submit it, struts2 throws this exception: WARNING: Error setting expression 'tag[]' with value '[Ljava.lang.String;@6c2a78' ognl.ExpressionSyntaxException: Malformed OGNL expression: tag[] [ognl

struts2 s:select value ognl expression

亡梦爱人 提交于 2019-12-12 19:18:04
问题 In Struts2 tutorial for s:select tag I've seen: <s:select label="Pets" name="petIds" list="petDao.pets" listKey="id" listValue="name" multiple="true" size="3" required="true" value="%{petDao.pets.{id}}" /> ^ ^ and my question: why value="%{petDao.pets.{id}}" ? why not simply value="%{petDao.pets.id}" ? what do those trailing curly braces mean? 回答1: This is an OGNL list projection to get all the id values as a list from petDao.pets , meaning all values in this <s:select> will be pre-selected.

How to use multiple forms / actions in a single view in Struts 2

我是研究僧i 提交于 2019-12-12 12:08:15
问题 I have a search box which is displayed on every page. The JSP code for the search box is inserted into every page via tiles. The search box has a form and an action class SearchAction which needs to preload some properties for drop down boxes. The SearchAction class has an input() method, which does this initialization. Some pages also have their own form in the main area. Also with their own action class. They also have an input() method which does some preloading. Is it possible to use two

Struts 2: Incorrect/misspelled getter and setter name of a field

六月ゝ 毕业季﹏ 提交于 2019-12-12 10:25:07
问题 I have declared a boolean variable as isABooleanValue in the Struts 2 modelbean and I am able to see the value by using this modelbean.aBooleanValue in jsp. getter looks like this public boolean isABooleanValue(){ return isABooleanValue; } setter looks like this public void setABooleanValue(boolean isABooleanValue){ this.isABooleanValue=isABooleanValue; } Jsp code <s:property value="modelbean.aBooleanValue" /> can anyone explain how an incorrect variable name be accessed like this from value

Struts2 iterator tag - access specific object value from list of objects

蹲街弑〆低调 提交于 2019-12-12 07:21:21
问题 Is there a way to access an attribute of specific object from list of objects. I've a List of Labs and each Lab object has multiple attributes. Using tag, can we access value of attribute1 of Lab1 object from the list of labs? Let's say: one of my Lab object has an attribute called labname with value "BP" and another lab object has labname of "A1c". Now, if I want to access the labvalue attribute of lab object with labname as "BP" how do I achieve it? 回答1: If you don't want to use a Map, that