开发者

Why is Eclipse/JSP parsing my JavaScript?

开发者 https://www.devze.com 2023-02-10 12:21 出处:网络
I have a JSP page which doesn\'t actually have any server tags in it so its basically an HTML page.But, my work is in love with JSP so I set it as a .jsp file.Anyhow, Tomcat is under the belief that m

I have a JSP page which doesn't actually have any server tags in it so its basically an HTML page. But, my work is in love with JSP so I set it as a .jsp file. Anyhow, Tomcat is under the belief that my JavaScript is in fact Java code and tries to parse it. I get a nice big error on the screen saying its not a real function, etc. Could anyone tell me why its doing this? Code below...

...
<script>

    $(function() {

        $.dragAndDrop({
            dom: {
                fileList: '#fileList tbody',
                contextMenu: '#fileContextMenu',
                dropzone: '#dropzone'
            },
            templates: {
                file: '<tr><td>${fileName}</td><td>${$.dragAndDrop.getDate()}</td><td>${$.dragAndDrop.parseSize(size)}</td></tr>'
            }
        });

    });

</script>
...

The error:

org.apach开发者_运维百科e.jasper.JasperException: /index.jsp(22,42) The function getDate must be used with a prefix when a default namespace is not specified
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)


${} marks expressions for evaluating via JSP. As you say you don't use any JSP, you can disable the expressions language by adding

<%@ page isELIgnored="true" %>

to your page.


It is likely the ${ notation

Try replacing this code ${$

with something like this $' + '{$

or $<%='{'%>$

I don't know if there is a proper way to escape that,, but what I just gave you should work.

See Google for more information. The top result looks good but I could not find how to do a proper escape: http://www.google.com/search?q=jsp+dollar+sign

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号