新手提問~麻煩前輩們了~~~~
使用Maven~
Spring 3.0.0.RELEASE
<<------- 掛 json pom ------->>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.4.0</version>
</dependency>
<<------- 在spring xml 設定 -------->>
<mvc:annotation-driven />
<<------- java 程式 -------->>
@Controller
@RequestMapping("/omgd")
public class OmGDController {
@Autowired
private QS qS;
@RequestMapping(value = "/testJsonGoGo.do", method = RequestMethod.POST)
public @ResponseBody QS testJson(HttpServletRequest req) {
System.out.println("========testJson==========");
System.out.println(request.getParameter("name"));
qS.setCNQry("1101");
qS.setCNeQry(1234);
qS.setLQ("setLevelQry");
qS.setNPQry(111111);
qS.setNSQry(222222);
qS.setPQry(2.5);
qS.setTQry(new Date());
return qS;
}
<<------- jsp 程式 使用jquery ------->>
<script type="text/javascript">
$(function() {
$("#btn1").click(function() {
$.post('<c:url value="/omgd/testJsonGoGo.do" />', {
name : "John",
time : "2pm"
}, function(data) {
alert("ihihihihihihihihhi"+data)
});
});
});
</script>
在jsp頁面 alert出不來json~~取不到值
不知道哪裡的問題Orz,,,,謝謝
--
ˊ──ˋ ︵▄▅▆▅▄ ▂▃▂
◣∕▂▃▂﹨◢ / ◣◣ ◢(( ))◣
◢\ ◥◥◥ /◣ ▕◥◤◤◤▋ ◢◥◥◤◣
|◥● ●◤︳ ▕◥● ●◤▏ ◤│● ●│◥
◣◥_▼_◤∕ ◥◥_–_◤◤ ▕◣_︸_◢▏
◥ ̄▼◣◣ ◢█▼█◣ ◢◥╱▼╲◤◣
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.231.67.242
※ 文章網址: https://www.ptt.cc/bbs/java/M.1542641918.A.5E9.html