我遇到了这个讨厌的异常,问题是我无法控制 get 字符串,因为它是由 3rd 方应用程序完成的。显然数字太长而无法解析为int ...
java.lang.NumberFormatException: For input string: "1286579871769"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:461)
at java.lang.Integer.valueOf(Integer.java:528)
at ognl.OgnlParserTokenManager.makeInt(OgnlParserTokenManager.java:63)
at ognl.OgnlParserTokenManager.TokenLexicalActions(OgnlParserTokenManager.java:1624)
at ognl.OgnlParserTokenManager.getNextToken(OgnlParserTokenManager.java:1498)
at ognl.OgnlParser.jj_ntk(OgnlParser.java:3099)
at ognl.OgnlParser.unaryExpression(OgnlParser.java:1079)
at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
at ognl.OgnlParser.andExpression(OgnlParser.java:352)
at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
struts2 片段:
<package name="ajax" namespace="/ajax" extends="default">
<default-interceptor-ref name="ajaxStack"/>
<action name="**">
<result>/WEB-INF/ajax/{1}.jsp</result>
</action>
</package>
和拦截器:
<interceptor-stack name="ajaxStack">
<interceptor-ref name="checkSession" />
<interceptor-ref name="checkAjax" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
checkAjax
只需确保用户已登录并将checkSession
会话参数存储在threadlocal
.