1

I have been trying to figure out if what I am trying is possible using JSTL. I am storing the following inside a database table

<c:when test="${row.actionType == 'com'}">  
  ${row.actionText}  
</c:when>       

thus I am storing the following String in a column in a table

<assign name="LocationID" expr="'${row.locationId}'"/> 
<submit next="/aotg/dynApp" namelist="UserID AppID LocationID"/> 

thus the above string for example gets written to ${row.actionText} and gets resolved. But of course the output in the JSTL is exactly as above without resolving the variable ${row.locationId} inside the String. Can you also somehow resolve the inner variable as well?

Is something like this even possible or do I need to hard code any parameters I might be using inside the JSTL page instead of trying to dynamically read it from the table?

4

2 に答える 2

2

.jspJSTL を含むファイルはファイルにコンパイルされ、ファイル.javaはファイルにコンパイルされ.classて JVM で実行されます。

c:whenブロックはコンパイル時に JSP に含まれていなかったので、クラス ファイルの実行時に出力テキストになります。

于 2013-01-05T01:51:22.310 に答える
0

今のところ、これを解決するためにマップを使用しました。もっと時間があれば、これを行うためのよりエレガントな方法があるかどうかを確認します。

  Map<String, String> varMap = new HashMap<String, String>();
  varMap.put("#locationId#", locationId.toString());    
  varMap.put("#mainMenu#", mainMenu);   
  varMap.put("#userId#", userId.toString());
  varMap.put("#appId#", appId.toString());    

  command = string;

  for (Map.Entry<String, String> entry : varMap.entrySet()) {

      command = command.replace(entry.getKey(), entry.getValue());
  }      

ありがとう

于 2013-01-06T00:39:47.470 に答える