问题描述
这是我的 JSF 文件的开头:
Here is the start of my JSF file:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
然而,http://www.icefaces.org/icefaces/components
和 http://java.sun.com/jsp/jstl/core
被突出显示红色,错误 URI 未注册
.这会导致许多其他后续标记显示为红色,并显示错误 element 'x' is not allowed here
.这是一张图片,显示了我的意思:
However, http://www.icefaces.org/icefaces/components
and http://java.sun.com/jsp/jstl/core
are highlighted in red with error URI is not registered
. This causes many other subsequent tags to appear in red with errors element 'x' is not allowed here
. Here is an image showing what I mean:
在搜索解决方案时,似乎有其他一些遇到相同问题的人通过获取外部资源"解决了这个问题.然而,这对我不起作用.对于icefaces xmlns xmlns:ace=http://www.icefaces.org/icefaces/components"
我收到错误:Error while fetching http://www.icefaces.org/icefaces/components
.对于 jstl xmlns xmlns:c=http://java.sun.com/jsp/jstl/core"
我收到错误:No XML at the location: http://java.sun.com/jsp/jstl/core
.
When searching for a solution, it appeared some others with the same problem solved it by doing "Fetch External Resource". However, this didn't work for me. For the icefaces xmlns xmlns:ace="http://www.icefaces.org/icefaces/components"
I get the error: Error while fetching http://www.icefaces.org/icefaces/components
. And for the jstl xmlns xmlns:c="http://java.sun.com/jsp/jstl/core"
I get the error: No XML at the location: http://java.sun.com/jsp/jstl/core
.
我还发现有人通过删除.idea
目录中的IntelliJ IDEA元数据文件workspace.xml
解决了这个问题.这似乎暂时有效……但过了一段时间似乎问题又回来了.我还必须重新配置几个我想避免的项目设置.
I also found some people solved it by deleting the IntelliJ IDEA metadata file workspace.xml
in the .idea
directory. This does seem to work temporarily... but then it seems the problem comes back after a while. I also have to reconfigure several project settings which I would like to avoid.
任何帮助将不胜感激.. 我不是很熟悉 xmlns 的东西,仍然是 Web 应用程序开发的初学者.谢谢!
Any help would be appreciated.. I'm not really familiar with the xmlns stuff and still a beginner to web app development. Thank you!
根据 Mark Vedder 的回答,我手动将外部资源添加到我的项目中,到目前为止问题还没有再次出现.
As per Mark Vedder's answer, I manually added external resources to my project and the problem has not resurfaced thus far.
推荐答案
对于未注册的资源,第一个解决方案是使用获取外部资源"快速修复.如果失败,就像在这种情况下对您一样(通常是因为位置"只是名义上的),您需要手动配置它.
With unregistered resources, the first solution is to use the "Fetch External Resource" quickfix. If that fails, as it has for you in this case, (usually because the "location" is in name only) you need to manually configure it.
手动配置
- 如果资源(即
.xsd
、.dtd
等)存在于您的某个库 jar 中,请跳至第 2 步.否则,下载一份副本的资源.把它放在你系统上方便的地方. - 在 IDEA 中,将光标置于错误上,通过键入 + 并选择手动设置外部资源"打开快速修复/意图"菜单.(如果您没有此选项(基于 IntelliJ IDEA 版本),请转到下一部分以获取说明.)
- 如果资源在 jar 中,请选择
Schemas
选项卡并从相应的 jar 中选择资源.如果您下载了它,请选择Explorer
选项卡(在 Mac 中可能命名为 Finder)并导航到并选择您下载的文件. - 单击确定",让 IDEA 为资源编制索引.
- If the resource (i.e. the
.xsd
,.dtd
, etc.) exists in one of your library jars, skip to step 2. Otherwise, download a copy of the resource. Put it somewhere convenient on your system. - In IDEA, with your cursor on the error, open the Quick Fix / Intentions menu by typing + and select "Manually Setup External Resource". (If you do not have this option (based on IntelliJ IDEA version) go to the next section for instructions.)
- If the resource is in a jar, select the
Schemas
tab and select the resource from the appropriate jar. If you downloaded it, select theExplorer
tab (may be named Finder in Mac) and navigate to and select the file you downloaded. - Click OK and let IDEA index the resource.
通过 IDE 设置进行编辑或设置
- 通过++ 或文件> 设置打开设置对话框.
- 要为所有未来的新项目进行配置以便此架构可用,请通过文件>其他设置>默认设置打开类似的对话框
- Open the settings Dialog via ++ or File > Settings.
- To configure for all future new projects so this schema is avaiable, open the similar dialog via File > Other Settings > Default Settings
更新
各种 JSF Taglib 定义(适用于 JSF 2.x 及更高版本)可以在 com.sun.faces 的
jar.com/sun/faces/metadata/taglib
目录中找到:jsf-impljsf-impl
JAR 文件可以从 maven central 等.
The various JSF Taglib definitions (for JSF 2.x and above) can be found in the com/sun/faces/metadata/taglib
directory of the com.sun.faces:jsf-impl
jar. The jsf-impl
JAR file can be downloaded from maven central among other places.
这篇关于JSF xmlns URI 未在 IntelliJ IDEA 中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!