天涯凝望y 2014-07-06 07:14
浏览 2382
已结题

struts2使用struts-dojo-tags,动态加载div不显示

这个是jsp页面

<%@ page contentType="text/html; charset=utf-8"%>  
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"></head>  
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>  
<head>
<sx:head/>
</head>  
<sx:div  
    href="ajaxServerAction.action"  
    showLoadingText="true"  
    loadingText="正在加载内容,请稍候"  
    errorText="对不起,加载资源失败,请重试"  
>  
</sx:div> 

然后是srtuts.xml

    <action name="ajaxServerAction" class="com.yuan.struts2.action.AjaxServerAction">
        <result type="stream">
            <param name="contentType">text/html</param>
            <param name="inputName">inputStream</param>
        </result>
    </action>

接着是action

package com.yuan.struts2.action;
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.opensymphony.xwork2.ActionSupport;

public class AjaxServerAction extends ActionSupport {  
    private InputStream inputStream;  
    public InputStream getInputStream() {  
        return inputStream;  
    }  


public String execute() throws Exception {  
    Thread.sleep(3000L);  
    inputStream = new ByteArrayInputStream("这是一个div的测试".getBytes("utf-8"));  
    return SUCCESS;  
}  

}

很简单的一个示例,可是网页报错,div不显示文字

Uncaught TypeError: Cannot read property '0' of null localhost:8080/Struts2-helloWorld/struts/dojo/struts_dojo.js:36
Uncaught TypeError: undefined is not a function localhost:8080/Struts2-helloWorld/struts/ajax/dojoRequire.js:22
Uncaught TypeError: Cannot read property 'push' of undefined localhost:8080/Struts2-helloWorld/ajax.jsp:34
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题