A workaround for creating a JSF WEB application in the new version of Idea 2017.3 that lacks XML.

Source: Internet
Author: User

Idea 2017.3 Creating a WEB application by default in a new version will most likely not automatically create an. xml file. Although there are some additions to the Servlet 3.0 specification starting from Java EE 6.0, the settings in the traditional Web. Xml are removed, but this also has limitations. For example, for a JSF application, you must add the configuration of the system's JSF Facelets Servlet in Web. XML and the settings for auto-start after deployment, including Context-param, Welcome-file-list, and so on, without SERVL corresponding annotations for ET 3.0. The new @WebServlet annotations in Servlet 3.0 only work on your own derived servlet, which is configured for the system's built-in JSF Facelets servlet, so you still need the Web. Xml. If idea 2017.3 doesn't help us automatically generate Web. xml for JSF, then we need to create it ourselves manually.

1. Create Web. xml

In idea, you create Web. XML for an application module, you can find the target Module in the Project structur dialog box, which contains a Web sub-module, click on the Web Submodule, and Deployment Desc on the right. Add a Web. xml to Riptors, note that its version is 3.1 the latest version, and then modify its path to the absolute path of your Module plus its own full path, similar to the following:/xxx/xxx/web/web-inf/web.xml.

2. Add the necessary general configuration in Web. xml

The newly created web. XML, in addition to the basic configuration of the namespace, is blank and requires some general basic configuration for the JSF Web App within the Web-app tag range, as follows:

<servlet>    <Servlet-name>Faces Servlet</Servlet-name>    <Servlet-class>Javax.faces.webapp.FacesServlet</Servlet-class>    <Load-on-startup>1</Load-on-startup></servlet><servlet-mapping>    <Servlet-name>Faces Servlet</Servlet-name>    <Url-pattern>*.xhtml</Url-pattern></servlet-mapping>    <Context-param>    <Param-name>Javax.faces.PROJECT_STAGE</Param-name>    <Param-value>Development</Param-value></Context-param><Context-param>    <Param-name>Javax.faces.FACELETS_SKIP_COMMENTS</Param-name>    <Param-value>True</Param-value></Context-param><Context-param>    <Param-name>Javax.faces.STATE_SAVING_METHOD</Param-name>    <Param-value>Server</Param-value></Context-param>    <welcome-file-list>    <Welcome-file>Index.xhtml</Welcome-file></welcome-file-list>

These are the most basic common configurations of JSF WEB applications in XML.

A workaround for creating a JSF WEB application in the new version of Idea 2017.3 that lacks XML.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.