在项目中碰到了一个问题现在有一个实体类。
public class TestEntity {
private String html;
private String other;
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
public String getOther() {
return other;
}
public void setOther(String otherl) {
this.other = other;
}
@Override
public String toString() {
return "TestEntity [html=" + html + ", other =" + other + "]";
}
}@RestController
@RequestMapping("/test")
public class TestController { @GetMapping("/test")
public TestEntity test(){
TestEntity testEntity = new TestEntity();
//实际数据从数据库中回去,数据保存整个HTML
testEntity.setHtml("<div id=\"0001\"></div>");
testEntity.setOther("id=123456789");
return testEntity;
}
}利用测试工具postman获取到的数据
{"html":"id=\"123456\"","other":"id=123456789"}前端正真需要的数据形式是{"html":"<div id="0001"></div>","other":"id=123456789"}
public class TestEntity {
private String html;
private String other;
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
public String getOther() {
return other;
}
public void setOther(String otherl) {
this.other = other;
}
@Override
public String toString() {
return "TestEntity [html=" + html + ", other =" + other + "]";
}
}@RestController
@RequestMapping("/test")
public class TestController { @GetMapping("/test")
public TestEntity test(){
TestEntity testEntity = new TestEntity();
//实际数据从数据库中回去,数据保存整个HTML
testEntity.setHtml("<div id=\"0001\"></div>");
testEntity.setOther("id=123456789");
return testEntity;
}
}利用测试工具postman获取到的数据
{"html":"id=\"123456\"","other":"id=123456789"}前端正真需要的数据形式是{"html":"<div id="0001"></div>","other":"id=123456789"}
解决方案 »
- 建立博客数据库问题??
- 看下面的验证输入的验证码的函数代码,为什么在servlet中can的session值都是pass?
- 求助,大家帮忙看看这段代码什么意思
- 纠结,支付问题
- BufferedReader对象的readLine()方法读到的中文字符长度算1(而不是2)
- 统计图形的问题
- 谁用过 WebRowSet 读入xml文件啊。 指点下
- 我写的文件下载JSP,TXT和DOC都能正常打开和保存,可就是XLS文件打开时说“丢失文件”,为什么???
- 初學JSP的问题
- 分現顯示時如何將上一頁輸入的數據帶到第下頁而不會丟失?
- ajax发请求后台接收不到cookie,页面上有cookie可以确定,并且没有跨域!
- 求助!调试访问localhost:8080/index页面没变化直接下载了跳转的页面代码
在浏览器和调试工具上结果是一样的我用你的代码测试了一下结果就是{"html":"<div id=\"0001\"></div>","other":"id=123456789"} ,你是不是有其他地方加了过滤器了?