//通过一个controller的访问将数据填充到另一个页面,并且将它挂到当前页面下
$(function() {
ajax("post?"+baseurl+"/platform/km/kmQuestionForumController/toQuestionDeataicontent?id="+formId,true,"detailcontent");
})
<div class="tabOne" id="detailcontent">
</div>
//请求后台
@RequestMapping("/toQuestionDeataicontent")
public ModelAndViewtoQuestionDeataicontent(HttpServletRequest request)
throws Exception{
ModelAndView mav = newModelAndView();
String questionId =request.getParameter("id");
KmQuestion kmQuestion = kmQuestionForumService
.getKmQuestionById(questionId);
// 发布时间
SimpleDateFormat dateFormater = newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String pubtime =dateFormater.format(kmQuestion.getCreationDate());
String pId =kmQuestion.getPublishUserId();
KmTopic kmTopic=null;
String topicName="";
String topicId =kmQuestion.getTopicId();
if(topicId!=null&& !"".equals(topicId)){
kmTopic = kmQuestionForumService.getTopicNameById(topicId);
topicName = kmTopic.getTopicName();
}
mav.addObject("pubtime",pubtime);
mav.addObject("pubName", sysUserLoader.getSysUserNameById(pId));
mav.addObject("topicName",topicName);
mav.addObject("kmQuestion",kmQuestion);
mav.addObject("content",kmQuestion.getContent());
mav.setViewName("avicit/im/km/kmcommunity/questionforum/kmQuestionDetailcontent");
return mav;
}
//kmQuestionDetailcontent.jsp页面
<%@ page language="java"contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"prefix="c"%>
<%@taglib prefix="sec" uri="/WEB-INF/tags/shiro.tld"%>
<%@taglib prefix="pt6" uri="/WEB-INF/tags/platform6.tld"%>
<%@ page import="avicit.platform6.commons.utils.ViewUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String entryId = request.getParameter("entryId");
String executionId = request.getParameter("executionId");
String taskId = request.getParameter("taskId");
String formId = request.getParameter("id");
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>详细</title>
<base href="<%=ViewUtil.getRequestPath(request)%>">
</head>
<script type="text/javascript">
$(function() {
viewContent();
});
function viewContent(){
var $iframe =$('<iframe src="about:blank" frameborder=0 />');
$iframe.ready(function()
{
var doc = $iframe[0].contentDocument;
var id="_frame_t";
$iframe.attr('width', '100%');
$iframe.attr('id', id);
doc.write(''
+ '<!DOCTYPEhtml><html><head><meta charset="utf-8"/>'
+ '<basehref="<%=ViewUtil.getRequestPath(request) %>">'
+ '<div>${content}</div>'
);
doc.close();
});
$iframe.appendTo($("#someContent"));
}
</script>
<body>
<div class="tabOne">
<div class="tabOneLeft" style="width: 86px;"><img class="roundimg" src="<%=request.getContextPath()%>/platform/sysuser/photo/upload/headerphoto?sysUserId=${pubId}" width="60px"height="60px" /><br><a id="pubName" >${pubName}</a></div>
<div class="tabOneRight">
<h3><a href="javascript:void(0)" id="title" title="标题" text="8888888">${kmQuestion.title}</a></h3>
<p class="tabOneP1">
<span id="pubtime">${pubtime}</span><span id="topicName">来自:${topicName }</span>
</p>
<P class="tabOneP2">
<div id="someContent">
</div>
<div id="content">
</div>
</P>
</div>
<div class="clear"></div>
</div>
</body>
</html>