简体   繁体   English

在Jasper JSP(tomcat)中打印“”而不是“ null”

[英]printing “” instead of “null” in jasper JSP (tomcat)

I'm migrating an application from Weblogic to tomcat (8.0.35). 我正在将应用程序从Weblogic迁移到tomcat(8.0.35)。 in Weblogic we used the "printNull = false" option which means that when a var is null, <%=var%> will print an empty string (instead of "null", as the Specification require), there is no equivalent option for Jasper jsp. 在Weblogic中,我们使用了“ printNull = false”选项,这意味着当var为null时,<%= var%>将打印一个空字符串(而不是规范所要求的“ null”),因此没有等效的选项碧玉jsp。

What can be done to achieve this behavior? 如何才能实现此行为?

ps changing the jsp files is not an option, there are simply too many of them. ps不能更改jsp文件,因为它们太多了。

I ended up patching jasper.jar, specifically method: public void visit(Node.Expression n) at Generator.java , now to the resulted .java file of the jsp prints empty string in case of nulls. 我最终修补了jasper.jar,具体方法是:在Generator.javapublic void visit(Node.Expression n)进行修补,现在将其Generator.java的jsp的.java文件在输出null的情况下会输出空字符串。

This is not a great solution, and that is exactly what i wanted to avoid, but it looks like there is no such option. 这不是一个很好的解决方案,而这正是我想要避免的,但是似乎没有这样的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM