Eclipse and struts syntax errors in JSP files

蹲街弑〆低调 提交于 2019-12-11 01:32:35

问题


I'm using eclipse as my java IDE and the project I'm working on uses struts. Eclipse is telling me on any page that has struts tags that the tags are syntax errors.

E.g. my tag <logic:equal shows this error

Syntax error on token "<", delete this token

but the page works just fine. How can I get eclipse to not show errors in these cases?

EDIT: Just noticed this is only when the tag is inside a <script> block. Tags in regular HTML work fine. Is this just an unresolved bug with my version of eclipse?

EDIT 2: posting a code block per the comment. Also added the CDATA to the file like the response suggests. I'm still getting the error in eclipse.

<script type="text/javascript" language="Javascript1.2">
//<![CDATA[
window.onload = function ()
{
    <logic:equal value="false" name="BeanKey" property="value(RecordNotFound)">
        alert("Record not found");
    </logic:equal>
}
//]]>
</script>

回答1:


Instead you can try like this,

<logic:present name="BeanKey" property="value(RecordNotFound)">
<logic:equal value="false" name="BeanKey" property="value(RecordNotFound)">
    <script>
        window.onload = function ()
        {
           alert("Record not found");
         }
    </script>
</logic:equal>
</logic:present>



回答2:


Enclose your JavaScript into a CDATA block:

<script type="text/javascript">
    <![CDATA[
        var javascript;
    ]]>
<script>


来源:https://stackoverflow.com/questions/18967771/eclipse-and-struts-syntax-errors-in-jsp-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!