jslayui跳转页⾯_layer页⾯跳转,获取html⼦节点元素的值⽅法1、jsp页⾯,携带值跳转到新页 original.jsp
var btnClick = {'click .shownewPage':function (e, value, row, index) {//点击按钮时触发时间
var Id = row.Id;
layer.open({
title: '跳转到新页',
type: 2,
content: '/switch/switchAction!getNewPage.do?Id='+Id, //struts配置⽂件指定的跳转路径
area: ['970px', '610px'],
shadeClose: true //点击遮罩关闭
});
}};
layui和bootstrap哪个好
2、后台跳转类 SwitchAction.java
@Scope(value = "prototype")
@Controller("SwitchAction ")
public class SwitchAction implements ServletRequestAware, ServletResponseAware, ModelDriven{
protected HttpServletRequest request;
protected HttpServletResponse response;
public String getNewPage(){
String Id = Parameter("Id"); //获取传递的参数
request.setAttribute("Id", Id); //设置属性值,传递参数
return "newPage"; //struts配置⽂件中跳转新页指定返回字符串
}
public String getnewHtml(){
JSONObject json = new JSONObject();
String Id = Parameter("Id");
PageRecord pageRecord = ObjectById(Id); //根据Id获取表内容
StringBuffer newHtml= new StringBuffer(pageRecord .getnewHtml);//得到表中String类型的html字符串
try {
} catch (IOException e) {
json.put("success", false);
e.printStackTrace();
}
}
}
3、struts配置⽂件,根据返回字符串跳转到新页
/p>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"/dtds/struts-2.0.dtd">
/WEB-INF/jsp/switch/newPage.jsp
4、将需要填充的html字符串填充到新页的表格(newPage.jsp)
var Id = '${Id}';
$(document).ready(function(){
//将html字符串填充到表格
$.ajax({
type:"post",
url:"/switch/SwitchAction!getNewHtml.do",
data: {
"Id":Id
},
success:function(data){
$("#hiddenTable").html(data);//将html字符串转化为jquery对象
var basichtml = $("#hiddenTable").find('#id-body').html();//查对象中⼦节点的值,即表格内容var str = "
序号属性名变更前变更后";
var basichtml = str + basichtml;//加上表头
$("#basicTable").html(basichtml)//将拼接的新字符串填充到表格
refreshTabOffset();//刷新body页⾯
},
error:function(data){
var str = data.html;
alert("加载失败。");
refreshTabOffset();
}
});
});
StringBuffer newPage = new StringBuffer();
newPage.append("序号属性名变更前变更后");
newPage.append("
");
resNo = resNo + 1;
newPage.append("
"+ resNo + "编码" + "" + origCode + "" + "" + newCode + "");
6、PageServiceImpl.java
@Scope("singleton")
@Service("PageService")//⾃动装载
public class PageServiceImpl implements PageService{
@Autowired //⾃动装载
PageDao pageDao;
@Override
public PageRecord getObjectById(String Id) {
ObjectById(Id);
}
7、PageDaoImpl.java
@Scope("singleton")
@Repository("PageDao")//⾃动装载
public class PageDaoImpl extends HibernateGenericDao implements PageDao{
@Override
public PageRecord PageRecord(PageRecord record) {
if (record != null) {
this.saveOrUpdate(record);
}
return record;
}
@Override
public PageRecord getObjectById(String Id) {
PageRecord PageRecord = null;
if(StringUtil.isEmpty(Id))
return null;
StringBuffer hql = new StringBuffer( "from PageRecord where Id=:Id ");//防⽌sql注⼊
Map map = new HashMap();//防⽌sql注⼊
map.put("Id", Integer.parseInt(Id)); //防⽌sql注⼊
List list = String(), map);
if(list.size()>0){
PageRecord = (0);
}
return PageRecord;
}
8、jsp页⾯引⽤插件
charset="UTF-8">
9、jsp页⾯引⽤CSS
rel="stylesheet">
rel="stylesheet">
href="/UIReference/DatetimePicker/css/bootstrap-datetimepicker.min.css" rel="external nofollow"
rel="stylesheet">
rel="stylesheet" type="text/css">
10、jsp页⾯布局
id="myModalBodyPage" οnscrοll="singleScroll();">
id="hiddenTable">
序号属性名变更前变更后
基本信息
id="basicTable">
以上这篇layer页⾯跳转,获取html⼦节点元素的值⽅法就是⼩编分享给⼤家的全部内容了,希望能给⼤家⼀个参考,也希望⼤家多多⽀持脚本之家。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。