English 中文(简体)
动态领域和/或人工方法
原标题:Dynamic Fields and/or Artificial Methods

我使用的是动态的<代码>Dataset模型,该模型(简而言之)以属性为特征,并以“代码”的形式储存。 页: 1

Dataset dataset = new Dataset();
dataset.setAttribute("name", "value");

......以后的恢复,如此......

String value = dataset.getAttribute("name");

......这为我的目的做了出色的工作。 但是,现在我站在我喜欢利用一个排气发动机来动态地生成超文本的地方。 在模板中,我很不理想的是,做许多<代码>{dataset.getAttribute(“名称”)。 如果在<上添加任何内容,我就能够制造人工方法,那将是很明智的。 例如,如果我这样做的话......

dataset.setAttribute("name", "value");

...... 我愿照此回来。

String name;
name = dataset.name;
//or
name = dataset.getName();

......然而,迄今为止,我没有能够将其赶走。 我在这里可以采取什么做法? 它是否甚至可行?

<><>>>>><>><>>><>>>>>

我的理解是,Velocity提供Propertyookup Rules,以试图解决dataset.name,dataset.get(“name”),而且如果Velocity t,我需要知道如何做到这一点。

问题回答

过去,我以目标网和阿马齐格会为生,积极开展了美术学会。 这样做的好处是,基本领域是安全的,效率更高(有利于繁荣价值)

您可以使用AOP技术或CGLib近似技术的动态星体。 AOP可以用来描述像以下这样的接收器:execution(public * com.bla.YourClass.get*()”

From what I ve seen, it s fairly common for template engines for Java to support both

  • getters/setters of the form getAttribute, and
  • implementation of the Map interface

Before you spend too much time looking for a more generic solution (assuming the above won t be supported like it is in Velocity), it s probably worth taking a look at the other engines to see if any of them don t support it. If all your possible targets do, then you re probably fine relying on it.

I m a big fan of making sure you actually have a problem before you spend the time to solve it.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签