org.noear.marsh.uadmin.controller.BaseController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marsh.uadmin Show documentation
Show all versions of marsh.uadmin Show documentation
Java project for marsh.uadmin
The newest version!
package org.noear.marsh.uadmin.controller;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Singleton;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.ModelAndView;
import org.noear.marsh.uadmin.model.ViewModel;
/**
* 基础控制器
*
* @author noear 2014-10-19
* @since 1.0
*/
@Singleton(false)
public abstract class BaseController {
/*视图数据模型*/
protected ViewModel viewModel = new ViewModel();
/*
* @return 输出一个视图(自动放置viewModel)
* @param viewName 视图名字(内部uri)
* */
public ModelAndView view(String viewName) {
//设置必要参数
viewModel.put("app", Solon.cfg().appTitle());
viewModel.put("css", "/_static/css");
viewModel.put("js", "/_static/js");
viewModel.put("img", "/_static/img");
return viewModel.view(viewName + ".ftl");
}
/*
* @return 输出一个跳转视图
* @prarm url 可以是任何URL地址
* */
public void redirect(String url) {
Context.current().redirect(url);
}
}