‘壹’ html镐庝箞镙峰儚java钖庡彴浼犻掑弬鏁帮纴java钖庡彴鍙堟槸镐庝箞鎺ユ敹鍙傛暟锛
1. 浣跨敤琛ㄥ崟镄勬柟寮忎紶鍙
鎶婅〃鍗曞厓绱犳斁鍦<form> 镙囩鹃噷闱锛岀洿鎺ユ彁浜よ〃鍗曞氨琛
2. 浣跨敤URL閲嶅畾钖戞柟寮忎紶鍊
姣斿傦细location.href = "login.do?method=checktel&name=lisi&age=10";
钖庡彴阃氲繃 request 瀵硅薄鎺ユ敹鍙傛暟
String name = request.getParameter("name");
String age = request.getParameter("age");
‘贰’ html5可以与java交互吗
单独的HTML不行,需要借助JavaScript之类的才行。
‘叁’ html代码如何和java代码交互,我只懂html代码和javascript交互。因为页面有一个button,向点击后触发事件
javascript
varparam="url="+$("#url").val();
$.ajax({
type:"POST",
url:"targetAction!targetMethod.action",
data:param,
dataType:"json",
success:function(json){
alert(json);
},
error:function(){
alert("连接超时");
}
});
java
ServletResponseresponse=ServletActionContext.getResponse();
response.resetBuffer();
response.setCharacterEncoding("utf-8");
response.getWriter().print(JSONArray.fromObject(data));
js端需要有个jquery,java端需要有个json-lib,这两个你可以到网上下载