2 a874721029 a874721029 于 2014.07.06 15:14 提问

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
Csdn user default icon
上传中...
上传图片
插入图片