日期:2014-05-17  浏览次数:20832 次

struts2 拦截器 拦截了jqgrid表格的url
项目中使用了 JQgrid用作表格展现。 其中的jquery 提交ajax方式
jQuery(document).ready(function() {
jQuery("#menulist").jqGrid( {
url :"menuAction_viewMenu.action",// 这里的url 断点不走方法
datatype : "json",
mtype : "post",

这个方法被struts2的拦截器拦截 ,访问时,按理来说应该返回一串json串,现如今直接跳转到登陆界面。请问这里应该怎么修改。 因为项目是半路接手,新手不太懂。还望各位前辈指教!

跪谢!!!!!

下面是配置文件

<package name="basePackage" extends="json-default">
      
       <interceptors>
        <interceptor name="keywordInterceptor" class="zyzy.common.interceptor.KeywordInterceptor"/>
<!-- 异常处理拦截器 -->
<interceptor name="exceptionInteceptor"
class="ExceptionInteceptor">
<param name="exceptionDisplay">exceptionDisplay</param>
</interceptor>

<!-- 定义异常拦截器栈 -->
<interceptor-stack name="exceptionStack">
<interceptor-ref name="defaultStack"></interceptor-ref>
<!-- <interceptor-ref name="exceptionInteceptor"></interceptor-ref> -->
<interceptor-ref name="keywordInterceptor">

</interceptor-ref>
</interceptor-stack>
       
        </interceptors>
        <!-- 定义默认拦截器 -->
<default-interceptor-ref name="exceptionStack" />

<!--定义全局输出结果 type="redirect" -->
<global-results>
<result name="info">/common/info.jsp</result>
<result name="timeOut">
/common/exception.jsp
</result>
<result name="exceptionDisplay">
/common/exception.jsp
</result>
</global-results>
<!-- 异常处理 -->
<global-exception-mappings>
<exception-mapping result="exceptionDisplay"
exception="zyzy.common.exception.BaseException">
</exception-mapping>
</global-exception-mappings>




拦截器:

public class KeywordInterceptor extends AbstractInterceptor{
    private final static String [] KEYWORD_MYSQL = {"|",";","$","%","@","'"," ","<>","()","","//+","CR","LF",",",".","document","eval","or","and","exec ","call ","insert ","select ","delete ",
"exe","update ","master","truncate ","declare ","#","java",
"drop ","create ","<script","/script>","iframe"};

@SuppressWarnings({ "rawtypes", "unchecked" })
public String intercept(ActionInvocation actionInvocation) throws Exception {

Map params = actionInvocation.getInvocationContext().getParameters();
if(params.size() > 0){
Iterator iterator = params.entrySet().iterator();
String temp_str;
Map.Entry temp;
int zCount = 0;
boolean test = false;
Map tempMap = new HashMap();
while(iterator.hasNext()){
temp = (Map.Entry)iterator.next();
if(temp.getValue() instanceof String)
temp_str = temp.getValue().toString();