javahtmlproperties-fileapache-commons-config

Show properties file content and edit it from web page


I have a properties file whose content would be like below

myprop=key1:value1,key2:value2 myprop2=key21:value21,key22:value22

second set

myprop3=key31:value31,key32:value32

How can I show the content on a web page and make it editable, so that, if I change the value of key2 to "value 444", it just changes that and everything else remains intact?

Apache commons configuration looks helpful but not sure how above can be accomplished


Solution

  • I solved it using Apache commons library.

    1. Get Builder object.

    2. Get Configuration object from Builder.

    3. Iterate through all the keys and their values and you can return it as a JSON response to a web page (using controller class).

    4. Make them editable their.

    5. When you update one value of a key; click on save will call another method end point wherein input param would be config key and updated value. which will do config.setProperty and will do builder.save();.

    6. By this, my property file would be updated.