页面跳转
1、js页面---->List.js
function articleShow(id,isRead,editType){
window.location.href = path +
"/appletManage/mpArticle/operatePage?id="+id
+"&isRead="+isRead
+"&editType="+editType
+"&pageType="+pageType;
};
2、controller
/**
* 文章新增\修改\查看
*
* @param model
* @return
*/
@RequestMapping(value = "/operatePage")
public String operatePage(Model model) {
Map<String, Object> map = getParameterMap();
Object editType = map.get("editType");
// 页面打开类型
model.addAttribute("editType", editType);
model.addAttribute("pageType", map.get("pageType"));
Map<String, Object> article = new HashMap<>();
if ("add".equals(editType)) {
//保留,区别场景
} else if ("edit".equals(editType)) {
article = service.getOne(new HashMap<String, Object>() {
private static final long serialVersionUID = 1L;
{
put("id", map.get("id"));
}
});
} else {
article = service.getOne(new HashMap<String, Object>() {
private static final long serialVersionUID = 1L;
{
put("id", map.get("id"));
}
});
}
if (article.containsKey("thumbnail_url") && null != article.get("thumbnail_url")
&& !StringUtils.isEmpty(article.get("thumbnail_url").toString())) {
article.put("thumbnail_url",this.getImgUrl(article.get("thumbnail_url").toString()));
}
model.addAttribute("article", article);
model.addAttribute("isRead", map.get("isRead"));
return "applet/article/mpArticleTab";
}
3、jsp---->Tab.jsp
<!--第一种,放在form表单里面-->
<input type="hidden" id="isRead" name="isRead" value="${isRead}"/>
<input type="hidden" id="id" name="id" value="${article.id}"/>
<input type="hidden" id="editType" name="editType" value="${editType}"/>
<!--第二种,放在外部-->
<script type="text/javascript">
var pageType = "${pageType}";
</script>
对应的js取值方式
//第一种
var isRead = $("#isRead").val();
var id = $("#id").val();
var editType = $("#editType").val();
//第二种,直接取值就行(全局)
params['type'] = pageType;