LoginSignup
4
4

More than 5 years have passed since last update.

IntelliJ Community Edition で Servlet 3.1 の web.xml を編集する

Posted at

IntelliJ の Community Edition で Servlet version 3.1 の web.xml を書くと、以下のようにエラーとなってしまう。 (Ultimate Edition ではエラーになりません)

web_xml_error.png

これは 3.1 用の XML Schema ファイルが IDE に組み込まれていないから。

ファイルを自力でダウンロードして設定をするとエラーにならなくなります。

  1. http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html#7 にある以下のファイルをどこかきまったディレクトリにダウンロードしておく

    • web-app_3_1.xsd
    • web-common_3_1.xsd
    • jsp_2_3.xsd
    • javaee_7.xsd
    • javaee_web_services_client_1_4.xsd
  2. Preferences の Languages & Frameworks > Schemas & DTDs の External Schemas & DTDs のボックスの下部にある「+」ボタンを押す

  3. URI のテキストボックスに「http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd」と入力し、 Explorer タブを選択する

  4. さきほどダウンロードした web-app_3_1.xsd ファイルをファイルブラウザから選択し、 OK を押す

    • ほかの4つの xsd ファイルについては明示的に指定しなくても xsd:include によってきちんと読み込まれているっぽい

以上で web.xml の編集でエラーにならなくなるし、補完もちゃんときくようになります。

参考文献: java - Missing schema definitions in IntelliJ - Stack Overflow

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4