java - Best Practice? Where do I put configuration parameters for my own application in Struts2? -
In the Java Servlet, Where should I put the configuration parameters for my Struts2 app? For example, my application has to set the time frame for user input, or save and read any stored files anywhere, or users can type incorrect passwords, maximum time I want to configure those things. How are people usually treated in the applications of Stratus 2? Any best practice? If you are familiar with the Then, to get Here is a brief example: & lt; Context-param> gt; . In desktop applications, we generally define our own configuration file.
ServletContext approach, then you have mentioned, You can stick with it in your
web.xml , just copy your
& lt; Context-param & gt; Add s.
ServletContext in your works, just execute
ServletContextAware and it will automatically be injected for you.
web.xml
& lt; Context param & gt; & Lt; Ultimate Name & gt; SomeSetting & lt; / Lastname & gt; & Lt; Ultimate Price & gt; SomeValue & lt; / Super-valued & gt; & Lt; / Reference param & gt;
Your work
The Public Class YourAction ActionSupport Component Extends ServletContextAware {Private ServletContext servletContext; Execute an override public string () Exception {strings some value = (string) subnetcontext.GetAttrite ("some setting"); Return success; } @ Override Public Wide Setserve Context (Last Serial Contact Reference) {this.servletContext = servletContext; }}
Comments
Post a Comment