在 Netbeans 7.3.1 中解析文件 JSP 或 JAVA 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19198755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:59:07  来源:igfitidea点击:

Error Parsing File JSP or JAVA in Netbeans 7.3.1

javajspnetbeans

提问by shareef

I migrated my project from Net beans 6.9.1 to Net Beans 7.3.1 and faced this annoying error a red exclamation icon on a random file jsp or java .

我将我的项目从 Net beans 6.9.1 迁移到 Net Beans 7.3.1,并遇到了这个恼人的错误,随机文件 jsp 或 java 上的红色感叹号图标。

I opened them and did not find any error.

我打开它们并没有发现任何错误。

I tried some suggestions after searching Google to disable html and jsp validation with no luck , another suggestion was to delete the cache files under user directory folder cache at C:\Users\home\.netbeans\6.9\var\cacheand also without luck !!!

我在搜索谷歌后尝试了一些建议以禁用 html 和 jsp 验证,但没有运气,另一个建议是删除用户目录文件夹下的缓存文件C:\Users\home\.netbeans\6.9\var\cache,也没有运气!!!

resolve bug incomplete

解决错误不完整

sample of java file error

java文件错误示例

采纳答案by shareef

You can try to do the following ... it worked for me

您可以尝试执行以下操作...它对我有用

rename the file of jsp or java to make the error go away for example

例如,重命名 jsp 或 java 的文件以使错误消失

test.java renamed to test_.java and then renamed back to test.java

test.java 重命名为 test_.java 然后重命名回 test.java

also same for jsp or xml

jsp 或 xml 也一样

references

参考

translate it to english

把它翻译成英文

By working with netbenas on some projects in some of these projects netbeans files mark some files with the symbol of admiration and the message "Error parsing file". This occurs because of a problem netbenas cache. The solution to this is to close the netbenas, clean (delete cache files and start the netbenas will return. Here are the different routes of some operating systems cache.

WINDOWS: C: \ Users \ AppData \ Local \ NetBeans \ Cache \ 7.2 \
MAC OS X: / Users // Library/Caches/NetBeans/7.2 /
UNIX: / home // .cache/netbeans/7.2

通过在其中一些项目中的一些项目中使用 netbenas,netbeans 文件将一些文件标记为钦佩的符号和消息“错误解析文件”。这是因为 netbenas 缓存出现问题。解决办法是关闭netbenas,clean(删除缓存文件,启动netbenas会返回。以下是一些操作系统缓存的不同路径。WINDOWS

:C:\Users\AppData\Local\NetBeans\Cache\7.2\
MAC OS X: / 用户 // 库/缓存
/NetBeans/7.2 / UNIX: / home // .cache/netbeans/7.2

good luck

祝你好运

回答by MrSnrub

Sometimes I had these issues with embedded JavaScripts in the JSP files, especially if the JavaScript parts contained JSTL EL expressions. In these cases the NetBeans project tree view showed a red exclamation mark ("Error parsing file") for the JSP file but when opening the file it didn't show a single error for a line.

有时我在 JSP 文件中嵌入 JavaScript 时遇到这些问题,尤其是当 JavaScript 部分包含 JSTL EL 表达式时。在这些情况下,NetBeans 项目树视图显示JSP 文件的红色感叹号(“Error parsing file”),但在打开文件时,它没有显示一行错误。

Idea 1: Add HTML comments to the JavaScript part in order to make the JSP/HTML syntax highlighter engine ignore these parts:

思路一:在 JavaScript 部分添加 HTML 注释,让 JSP/HTML 语法高亮引擎忽略这些部分:

<b>Very primitive example</b>
<script type="text/javascript">// <!--
    var foo = ${myBean.bar};   // -->
</script>

Idea 2: Put as much JavaScript code as possible into external JS files. In general it's a good idea to avoid JavaScript code in JSP/HTML files as this allows you to use additional anti XSS measureslike X-XSS-Protection.

想法 2:将尽可能多的 JavaScript 代码放入外部 JS 文件中。一般来说,避免在 JSP/HTML 文件中使用 JavaScript 代码是个好主意,因为这允许您使用额外的反 XSS 措施,X-XSS-Protection

回答by Mr Hoelee

May occur if having unnecessary lambda return statement in Netbeans 8.2

如果在 Netbeans 8.2 中有不必要的 lambda return 语句,可能会发生

回答by rajani

No need to worry ! This is because after you make any changes in servets or jspyou need to save your file.

不用担心 !这是因为在您对服务进行任何更改后,或者jsp您需要保存文件。

So first save your file then everything goes well. This worked for me!

所以首先保存你的文件然后一切顺利。这对我有用!

回答by Barani r

i fixed "Error Parsing File" in my Java file (IDE: Netbeans) by just deleting the space before the bottom most "}" and press enter. Basically, just do some modification in the file and save it again.

我修复了 Java 文件(IDE:Netbeans)中的“错误解析文件”,方法是删除最底部“}”之前的空格并按 Enter。基本上,只需在文件中进行一些修改并再次保存即可。

回答by Lucas Basquerotto

In my case I had a class similar to the following and Netbeans (8.2) showed no error inside the file, but in the file icon it showed a error of parsing the file:

在我的例子中,我有一个类似于以下的类,Netbeans (8.2) 在文件中没有显示错误,但是在文件图标中它显示了解析文件的错误:

public class FileUploadUtil {

    private static interface WriteToFile {
        public void run(File file) throws IOException;
    }

    private static interface UseFile {
        public void run(File file) throws IOException;
    }

    private static void createAndUseTempFile(InputStream is, UseFile use) throws IOException {
        createAndUseTempFile((file) -> {
            try (FileOutputStream fos = new FileOutputStream(file)) {
                byte[] bytes = new byte[1024];
                int read;

                while ((read = is.read(bytes)) != -1) {
                    fos.write(bytes, 0, read);
                }

                fos.flush();
            }
        }, use, "tmp"); 

    }

    private static void createAndUseTempFile(Image image, UseFile use, String extension) throws IOException {
        createAndUseTempFile((file) -> image.writeToFile(file), use);
    }

    private static void createAndUseTempFile(WriteToFile write, UseFile use, String extension) throws IOException {
        File file = null;

        try {
            String key = System.currentTimeMillis() + "-" + SecurityUtil.generateUUID();
            String suffix = (extension != null) ? ("." + extension) : null;
            file = File.createTempFile(key, suffix);
            write.run(file);            
            use.run(file);
        } finally {
            if (file != null) {
                file.delete();
            }
        }
    }
}

The method:

方法:

private static void createAndUseTempFile(Image image, UseFile use, String extension) throws IOException {
    createAndUseTempFile((file) -> image.writeToFile(file), use);
}

should be:

应该:

private static void createAndUseTempFile(Image image, UseFile use, String extension) throws IOException {
    createAndUseTempFile((file) -> image.writeToFile(file), use, extension);
}

but Netbeans showed no errors inside the file, so I tried to reload the project, rename the file and so on.

但是 Netbeans 没有显示文件中的错误,所以我尝试重新加载项目,重命名文件等等。

Then I tried to compile with gradle and received the error:

然后我尝试用 gradle 编译并收到错误:

FileUploadUtil.java:95: error: incompatible types: InputStream is not a functional interface

Then I realized that it was trying to call createAndUseTempFile(InputStream is, UseFile use)instead of createAndUseTempFile(WriteToFile write, UseFile use, String extension), but because the InputStream is not a functional interface and doesn't extends/implements an interface that has a method that receives a File, it couldn't call that method (and shouldn't!).

然后我意识到它试图调用createAndUseTempFile(InputStream is, UseFile use)而不是createAndUseTempFile(WriteToFile write, UseFile use, String extension),但是因为 InputStream 不是一个功能接口并且没有扩展/实现一个具有接收 a 的方法的接口File,它不能调用该方法(并且不应该!)。

I think it's a Netbeans bug in this case, because it should show the error in that line.

我认为在这种情况下这是一个 Netbeans 错误,因为它应该在该行中显示错误。