相关疑难解决方法(0)

发出返回JSON值的问题

我没有收到来自服务器的JSON类型数据的响应.

我正在使用JSON插件.

jQuery( "#dialog-form" ).dialog({ 
    autoOpen: false,
    height: 500,
    width: 750,
    modal: true,
    buttons :{
        "Search" : function(){
            jQuery.ajax({type : 'POST',
            dataType : 'json',
             url : '<s:url action="part" method="finder" />',
         success : handledata})
        }
    }
});
var handledata = function(data)
{
    alert(data);
}
Run Code Online (Sandbox Code Playgroud)

如果dataType = 'json'我没有得到任何回复,但如果我没有提及任何回复,dataType我将获得该页面的HTML格式.

public String list(){
    JSONObject jo = new JSONObject();
    try {
        Iterator it = findList.iterator();
        while(it.hasNext()){
             SearchResult part = (SearchResult) it.next();
             jo.put("col1",part.getcol1());
             jo.put("col2",part.getcol2());
        }
        log.debug("--------->:"+jo.toString());
    } catch (Exception e) {
        log.error(e); …
Run Code Online (Sandbox Code Playgroud)

java ajax jquery json struts2

9
推荐指数
2
解决办法
2万
查看次数

无法使用超链接实现Struts 2令牌拦截器

我尝试使用<s:url ..标记实现令牌拦截器,但在第一次单击时显示错误.即The form has already been processed or no token was supplied, please try again.

我想实现这个拦截器,因为如果用户已经删除了一行并再次刷新页面,那么同一个动作不应该再次执行.

<s:url id="linkdelete" action="DeleteLatestUpload.action" namespace="/admin/insecure/upload">
     <s:param name="latestUploadId" value="latestUploadId"></s:param>
     <s:token name="token"></s:token>
</s:url> 
<a href='<s:property value="#linkdelete"/>' style="color: white;text-decoration:  none;" class="delbuttonlink">Clear current Uploads</a>
Run Code Online (Sandbox Code Playgroud)

和我的struts.xml:

 <action name="DeleteLatestUpload" class="v.esoft.actions.UploadExcel" method="deleteUploads">                   
     <interceptor-ref name="token"></interceptor-ref>
     <interceptor-ref name="basicStack"></interceptor-ref>  
     <result name="success" type="tiles"> uploadforward</result>
     <result name="invalid.token" type="tiles">uploadforward </result>
 </action>
Run Code Online (Sandbox Code Playgroud)

java jsp struts2 token interceptor

5
推荐指数
2
解决办法
7945
查看次数

标签 统计

java ×2

struts2 ×2

ajax ×1

interceptor ×1

jquery ×1

json ×1

jsp ×1

token ×1