支持返回多视图方法

This commit is contained in:
shuzheng 2017-03-25 01:52:09 +08:00
parent da347c76dc
commit 79dd5dfe85
2 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.zheng.common.base;
import com.zheng.common.util.PropertiesFileUtil;
import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.session.InvalidSessionException;
import org.slf4j.Logger;
@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
/**
* 控制器基类
@ -41,4 +43,23 @@ public abstract class BaseController {
return "/error.jsp";
}
/**
* 返回jsp视图
* @param path
* @return
*/
public static String jsp(String path) {
return path + ".jsp";
}
/**
* 返回thymeleaf视图
* @param path
* @return
*/
public static String thymeleaf(String path) {
String folder = PropertiesFileUtil.getInstance().get("app.name");
return File.separator.concat(folder).concat(path);
}
}

View File

@ -27,7 +27,7 @@ public class IndexController extends BaseController {
*/
@RequestMapping(value = "/jsp", method = RequestMethod.GET)
public String jsp() {
return "/index.jsp";
return jsp("/index");
}
/**
@ -50,7 +50,7 @@ public class IndexController extends BaseController {
user.setName("lisi");
users.add(user);
model.addAttribute("users", users);
return "/zheng-demo/index";
return thymeleaf("/index");
}
}