簡體   English   中英

如何從控制器傳遞json字符串以查看

[英]how to pass the json string from controller to view

嗨,我正在使用Spring mvc項目,因為我必須從控制器傳遞json字符串以查看從控制器返回的代碼是:

返回model.addObject(“ response”,Response.getResults()。toJSONString());

而jsp代碼是:

    <%@ page language="java" content Type="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <title>Response value</title>
        </head>
        <body>
            Response is : <c:out value="${response}" />
        </body>
    </html>`

我已經在郵遞員上運行了調用,它成功運行了,但是無法顯示響應字符串,它僅在郵遞員上顯示了jsp編碼。

誰能幫我解決這個問題?

在使用Spring Rest Services時,@ RestController扮演着重要角色。

@RestController
@RequestMapping("/yourmapping")
public class yourController {

@RequestMapping(method = RequestMethod.GET)
  public <returnType> getAll() {
    return <response>;
  }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM