我正在将我的应用程序从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,但是它不起作用。
我得到以下错误:
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_QUOTE_ESCAPING=false
发布于 2013-02-20 16:31:28
如果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();
}
}https://stackoverflow.com/questions/14743805
复制相似问题