Web Application new project wizard customize Servlet version
已回答
Our plugin creates a new entry in the Java new application wizard as a child of Web Application.
Currently, Web Application defaults to creating a web.xml with servlet version 3.1. I'd like to customize this to force version 2.5 (and in the future be able to vary the version based on selections in our new application wizard panel).
If possible, could you point me in the right direction?
请先登录再写评论。
hi,
1. code
2. extension point
Thanks Sergey,
Did you meant to suggest that I add that Startup callback in my JavaeeFrameworkSupportContributor extension?
Maybe I'm misunderstanding your suggestion, but it looks like JavaeeFrameworkSupportContributor#setupFrameworkSupport gets invoked after the web.xml file gets generated. I need the project wizard to generate a web.xml with my specified servlet version. This still resulted in a web.xml with Servlet version 3.1.
Thanks again for the help.
Follow up:
Looking again I see that your suggestion entails modifying the xml model directly. This makes sense, but it did not work. I'll investigate more, but any suggestions welcome.
As a side question: is there a way, instead of updating the web.xml's xml model directly, to modify the Servlet version at a higher level (e.g. similar to what selecting a different servlet version from the dropdown in the new project wizard would do)?
See JavaeeFrameworkSupportProviderBase#addSupport: ConfigFileVersion determines what version gets created, but I don't know of any way to hook into this.
I'd like to hear your opinion on this, but this approach seems more robust: for example, I'd also like the schema url in web.xml to be updated to reference the updated servlet version.
Another update:
Looks like your original suggestion works. I just had to wrap the write in a write action.