首页>代码>Spring MVC、Vue、layui、layer等成熟技术开发个人博客网站>/ExcellentCodeProject/src/main/java/com/ecp/common/communal/controller/DynamicController.java
package com.ecp.common.communal.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONObject;
import com.ecp.common.communal.util.KeywordsUtils;
/**
* 动态加载数据或者公共页面
*/
@Controller
@RequestMapping(path = {"/common/communal/dynamic/"})
public class DynamicController {
private static final Logger logger = LoggerFactory.getLogger(DynamicController.class);
/**
* 进入门户首页
* @param request
* @param response
* @param modelAndView
* @param session
* @param paramsJsonStr
* @return
*/
@RequestMapping(path = {"gotoPortalIndex"}, method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView gotoPortalIndex (HttpServletRequest request, HttpSession session,
HttpServletResponse response, ModelAndView modelAndView, String paramsJsonStr) {
try {
request.setCharacterEncoding(KeywordsUtils.UTF_8);
response.setCharacterEncoding(KeywordsUtils.UTF_8);
System.out.println("==========前端传过来的参数:" + paramsJsonStr);
JSONObject paramsJO = new JSONObject();
if (StringUtils.isNotBlank(paramsJsonStr)) {
paramsJO = JSONObject.parseObject(paramsJsonStr);
}
System.out.println("==========前端传过来的参数转化成JSONObject:" + paramsJO);
JSONObject webUserInfoJO = (JSONObject) session.getAttribute(KeywordsUtils.YDM_WEB_USER);
if (webUserInfoJO!=null) {
modelAndView.addObject(KeywordsUtils.YDM_WEB_USER_INFO, webUserInfoJO);
}
modelAndView.setViewName("portal/index/index");
} catch (Exception e) {
e.printStackTrace();
}
return modelAndView;
}
/**
* 加载门户头部
* @param request
* @param session
* @param response
* @param modelAndView
* @param paramsJsonStr
* @return
*/
@RequestMapping(path = {"loadPortalTop"}, method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView loadPortalTop (HttpServletRequest request, HttpSession session,
HttpServletResponse response, ModelAndView modelAndView, String paramsJsonStr) {
try {
request.setCharacterEncoding(KeywordsUtils.UTF_8);
response.setCharacterEncoding(KeywordsUtils.UTF_8);
System.out.println("==========前端传过来的参数:" + paramsJsonStr);
JSONObject paramsJO = new JSONObject();
if (StringUtils.isNotBlank(paramsJsonStr)) {
paramsJO = JSONObject.parseObject(paramsJsonStr);
}
System.out.println("==========前端传过来的参数转化成JSONObject:" + paramsJO);
JSONObject tempWebUserJO = (JSONObject) session.getAttribute(KeywordsUtils.YDM_WEB_USER);
JSONObject webUserJO = new JSONObject();
if (tempWebUserJO!=null && !tempWebUserJO.isEmpty()) {
for (String key : tempWebUserJO.keySet()) {
if (key.equals("NAME_") || key.equals("EMIAL_")) {
webUserJO.put(key, tempWebUserJO.get(key));
}
}
}
if (webUserJO!=null && !webUserJO.isEmpty()) {
modelAndView.addObject(KeywordsUtils.YDM_WEB_USER_INFO, webUserJO);
} else {
modelAndView.addObject(KeywordsUtils.YDM_WEB_USER_INFO, null);
}
modelAndView.setViewName("portal/include/top");
} catch (Exception e) {
e.printStackTrace();
}
return modelAndView;
}
/**
* 加载门户左部
* @param request
* @param response
* @param modelAndView
* @param paramsJsonStr
* @return
*/
@RequestMapping(path = {"loadPortalLeft"}, method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView loadPortalLeft (HttpServletRequest request, HttpSession session,
HttpServletResponse response, ModelAndView modelAndView, String paramsJsonStr) {
try {
request.setCharacterEncoding(KeywordsUtils.UTF_8);
response.setCharacterEncoding(KeywordsUtils.UTF_8);
System.out.println("==========前端传过来的参数:" + paramsJsonStr);
JSONObject paramsJO = new JSONObject();
if (StringUtils.isNotBlank(paramsJsonStr)) {
paramsJO = JSONObject.parseObject(paramsJsonStr);
}
System.out.println("==========前端传过来的参数转化成JSONObject:" + paramsJO);
modelAndView.setViewName("portal/include/left");
} catch (Exception e) {
e.printStackTrace();
}
return modelAndView;
}
/**
* 加载门户底部
* @param request
* @param response
* @param modelAndView
* @param paramsJsonStr
* @return
*/
@RequestMapping(path = {"loadPortalBottom"}, method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView loadPortalBottom (HttpServletRequest request, HttpSession session,
HttpServletResponse response, ModelAndView modelAndView, String paramsJsonStr) {
try {
request.setCharacterEncoding(KeywordsUtils.UTF_8);
response.setCharacterEncoding(KeywordsUtils.UTF_8);
System.out.println("==========前端传过来的参数:" + paramsJsonStr);
JSONObject paramsJO = new JSONObject();
if (StringUtils.isNotBlank(paramsJsonStr)) {
paramsJO = JSONObject.parseObject(paramsJsonStr);
}
System.out.println("==========前端传过来的参数转化成JSONObject:" + paramsJO);
modelAndView.setViewName("portal/include/bottom");
} catch (Exception e) {
e.printStackTrace();
}
return modelAndView;
}
}
最近下载更多
1690356080 LV38
2023年11月12日
123456nty LV37
2022年4月8日
ljm2s LV3
2021年9月24日
seve980508 LV1
2020年5月26日
499755609 LV8
2020年4月7日
jiajia91323 LV23
2019年12月13日
powerful LV7
2019年12月4日
admin123456686 LV10
2019年11月1日
xiongtianming18 LV12
2019年9月26日
wzsq20 LV12
2019年9月22日

最近浏览