zoukankan      html  css  js  c++  java
  • struts2 注解Action报错

    Action类中配置注解跳转:

    @Action("sample")
    @Results({@Result(name = "ssss", location = "/Pages/sample/sampleList.jsp")})

    public class SampleAction extends ActionSupport {

      ......

      public String allSamples() {
        log.info("所有样本分页显示");
        if (page == null) {
          page = new Page(10, 1);
        }
        samplePageList = sampleService.getSampleLimit(page);
        return "ssss";
      }

      ......

    }

    jsp页面调用: 

      $.get("sample!allSamples",{},function(responseText){
        $("#sampleList").load(responseText);
      });

    问题: 如果在地址栏直接跳转 http://localhost:8080/proName/sample!allSamples   可以成功跳转到页面 sampleList.jsp

       但是在jsp页面通过jquery调用,却总是报错:

    Could not find action or result
    /Lims/%3Ctable?_=1373592165761
    There is no Action mapped for namespace [/] and action name [<table] associated with context path [/Lims]. - [unknown location]
        at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
        at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)
        at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)

    花了半天时间查找struts注解可能会犯的错误,但是还是没有找到。原来就把错误定位在了location路径写错了,但是发现写错路径的话页面会报404错误,因此可以证明页面路径是没有问题的。

      第二天通过问朋友才发现错误:$("#sampleList").load(responseText);           就是这句话的错误!

    原因:在每一个匹配元素的load事件中绑定一个处理函数。如果绑定给window对象,则会在所有内容加载后触发,包括窗口,框架,对象和图像。如果绑定在元素上,则当元素的内容加载完毕后触发。上面这句$("#sampleList").load(responseText);被写在了$.ready()里面,也就是说本页面还没有被加载完,所以找不到id为sampleList的元素,因此也就不会触发返回页面的任何样式。

    解决:$("#sampleList").load(responseText); 修改为$("#sampleList").html(responseText);问题解决。。。。。。

  • 相关阅读:
    border——边框属性
    CSS1,CSS2选择器详解
    CSS样式表与HTML结合的方法
    详细解析HTML基础结构
    jquery 解析xml
    asp.net js调用后台方法
    asp.net利用剪切板导出excel
    webform 不实用office控件导出excel StringBuilder 类型拼接字符串表格导出excel
    Android再学习-20141018-布局-进度条
    Android再学习-20140928-布局
  • 原文地址:https://www.cnblogs.com/daisyleamo/p/3185586.html
Copyright © 2011-2022 走看看