String Constants Vs Resource Bundle in Java Web Application

From last year, we created an application in which we used String static constants to store constants. like public static final String PAYMENT_CHEQUE = "check"; Where ever I require, that is, on the jsp pages, as well as in the Action class, I will refer to the Above String Constant I think after considering the resource package, file properties, My question

  • Is there any performance if I use the properties file compared to the Static string constant?
  • Which is better Static string constant and key file properties A pair of values?
  • Is this ideal a good idea, we use the static constant String (for marking) in jsp?

Please offer me

+3
source share
2 answers

In general, using hard-coded strings is a bad idea because it means that each change requires a new compilation-deployment cycle, while using a properties file means that the application needs to be restarted and nothing else (although some would say that yourself is a high price to pay). Another advantage of using the properties file is the ability to switch languages ​​by switching the application to another file - much more reasonable than having several sets of constant labels in the code.

, , ma , , ( !). , , - , .

+2

:

  • , . , .
  • ; .
  • Java, JSP, JSTL ( ).
+1

Source: https://habr.com/ru/post/1733752/


All Articles