首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Websphere中的-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING作为

Websphere中的-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING作为
EN

Stack Overflow用户
提问于 2013-02-07 04:53:14
回答 1查看 2.3K关注 0票数 2

我正在将我的应用程序从Tomcat 7迁移到WebSphere 8.5

Tomcat 7中我使用了

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

为了在编译JSP页面时重新处理双引用问题,我在WebSphere中搜索它的eqvi叶参数。

我找到了一个Web容器自定义属性

com.ibm.wsspi.jsp.evalquotedandescapedexpression=true

对于WAS 8.5,但是它不起作用。

我得到以下错误:

代码语言:javascript
复制
JSPG0055E: Unable to create an xml attribute from name [] value [%]

折页情况下基本出现误差

代码语言:javascript
复制
<html:input value="<%="abc"%>"></html:input>

现在的解决办法是

代码语言:javascript
复制
<html:input value='<%="abc"%>'></html:input>

但是在我的例子中是不可能的,因为JSP太多了,在Tomcat中这个问题是通过添加以下属性来解决的

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-20 16:31:28

如果JSP太多,可以尝试下一个转换代码。它涵盖了许多情况,在您可以调整这些特殊情况之后:

代码语言:javascript
复制
package test;

import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.LineNumberReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JSPParser {
    public static void main(String[] args) throws Exception {
        Pattern pattern = Pattern
            .compile("([A-Za-z]+\\w?\\s*=\\s*(\")<%=\\s*[^%>]*\"+[^>]*\\s*%>(\")\\s*)");

        // Pass the input JSP in the first argument
        FileReader fr = new FileReader(args[0]);
        LineNumberReader lnr = new LineNumberReader(fr);
        String fileName = args[0];
        int n = fileName.lastIndexOf("/");

        // You must have a "was" subdirectory from the source location
        fileName = fileName.substring(0, n + 1) + "was/" + fileName.substring(n + 1);

        FileOutputStream fos = new FileOutputStream(fileName);
        String line = null;
        while ((line = lnr.readLine()) != null) {
            Matcher matcher = pattern.matcher(line);
            while (matcher.find()) {
                n = matcher.groupCount();
                for (int i = 2; i <= n; i++) {
                    line = line.substring(0, matcher.start(i)) + "'"
                            + line.substring(matcher.end(i));
                }
            }
            fos.write(line.getBytes());
            fos.write("\n".getBytes());
        }
        fos.flush();
        fos.close();
        lnr.close();
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14743805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档