Java -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_在Websphere中转义为

Java -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_在Websphere中转义为,java,jsp,websphere,Java,Jsp,Websphere,我正在将我的应用程序从tomcat7迁移到websphere8.5 在tomcat7中,我使用了 -Dorg.apache.jasper.compiler.Parser.STRICT\u QUOTE\u ESCAPING=false 为了在编译JSP页面时重新考虑双引号问题,我正在WebSphere中搜索它的eqvivalent参数 我找到了一个Web容器自定义属性 com.ibm.wsspi.jsp.evalquotedandscapedexpression=true 因为是8.5,但它不起作

我正在将我的应用程序从
tomcat7
迁移到
websphere8.5

tomcat7
中,我使用了

-Dorg.apache.jasper.compiler.Parser.STRICT\u QUOTE\u ESCAPING=false

为了在编译
JSP
页面时重新考虑双引号问题,我正在
WebSphere
中搜索它的eqvivalent参数

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

com.ibm.wsspi.jsp.evalquotedandscapedexpression=true

因为
是8.5
,但它不起作用

我发现以下错误:

JSPG0055E: Unable to create an xml attribute from name [] value [%]
以下情况基本上发生了错误

<html:input value="<%="abc"%>"></html:input>

现在的解决办法是

<html:input value='<%="abc"%>'></html:input>


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

-Dorg.apache.jasper.compiler.Parser.STRICT\u QUOTE\u ESCAPING=false


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

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();
    }
}
封装测试;
导入java.io.FileOutputStream;
导入java.io.FileReader;
导入java.io.LineNumberReader;
导入java.util.regex.Matcher;
导入java.util.regex.Pattern;
公共类JSPPAR{
公共静态void main(字符串[]args)引发异常{
图案
.编译(“([A-Za-z]+\\w?\\s*=\\s*(\”)]*\“+[^>]*\\s*%>(\”\\s*)”;
//在第一个参数中传递输入JSP
FileReader fr=新的FileReader(args[0]);
LineNumberReader lnr=新的LineNumberReader(fr);
字符串文件名=args[0];
int n=fileName.lastIndexOf(“/”);
//您必须具有源位置的“was”子目录
fileName=fileName.substring(0,n+1)+“was/”+fileName.substring(n+1);
FileOutputStream fos=新的FileOutputStream(文件名);
字符串行=null;
而((line=lnr.readLine())!=null){
匹配器匹配器=模式匹配器(线);
while(matcher.find()){
n=matcher.groupCount();

对于(int i=2;i,在Websphere中,您是否在使用和不使用
evalquotedandscapedexpression
时都会遇到相同的错误?是的,我也会遇到相同的错误。您可以描述一下如何设置该属性吗?在管理控制台中转到:Websphere application servers>>Web容器>自定义属性>新建…”但在我的例子中,这是不可能的,因为有这么多JSP“难道你不能用正则表达式创建简单的批处理/bash脚本来替换所有发生的事件吗?也许这是一种解决方法,但正如你所说的,这是一种有效的解决方案。