本文整理汇总了Java中org.nutz.mvc.View类的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
View类属于org.nutz.mvc包,在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: make
import org.nutz.mvc.View; //导入依赖的package包/类
public View make(Ioc ioc, String type, String value) {
if ("fm".equalsIgnoreCase(type) || "ftl".equalsIgnoreCase(type)) {
if (freeMarkerConfigurer == null) {
for (String name : ioc.getNames()) {
if (iocName.equals(name)) {
freeMarkerConfigurer = ioc.get(FreeMarkerConfigurer.class);
break;
}
}
if (freeMarkerConfigurer == null) {
Configuration configuration = new Configuration();
freeMarkerConfigurer = new FreeMarkerConfigurer(configuration, Mvcs.getServletContext(),"WEB-INF", ".html", null);
freeMarkerConfigurer.init();
}
}
return new WindowsFreemarkerView(freeMarkerConfigurer, value);
}
return null;
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:20,代码来源:WindowsFreemarkerViewMaker.java
示例2: handle
import org.nutz.mvc.View; //导入依赖的package包/类
/**
* 用一个wxHandler处理对应的用户请求
*/
public static View handle(WxHandler wxHandler, HttpServletRequest req, String key) throws IOException {
if (wxHandler == null) {
log.info("WxHandler is NULL");
return HttpStatusView.HTTP_502;
}
if (!wxHandler.check(req.getParameter("signature"), req.getParameter("timestamp"), req.getParameter("nonce"), key)) {
log.info("token is invalid");
return HttpStatusView.HTTP_502;
}
if ("GET".equalsIgnoreCase(req.getMethod())) {
log.info("GET? return echostr=" + req.getParameter("echostr"));
return new ViewWrapper(new RawView(null), req.getParameter("echostr"));
}
WxInMsg in = Wxs.convert(req.getInputStream());
in.setExtkey(key);
WxOutMsg out = wxHandler.handle(in);
if (out != null)
Wxs.fix(in, out);
return new ViewWrapper(WxView.me, out);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:24,代码来源:Wxs.java
示例3: match
import org.nutz.mvc.View; //导入依赖的package包/类
public View match(ActionContext ac) {
String apikey = ac.getRequest().getHeader("U-ApiKey");
if (apikey == null) {
apikey = ac.getRequest().getHeader("ApiKey");
}
if (apikey != null) {
IotUser itokey = dao.fetch(IotUser.class, apikey);
if (itokey != null) {
ac.getRequest().setAttribute(Zs.UID, itokey.getUserId());
return null;
}
}
if ("GET".equals(ac.getRequest().getMethod()) && !ac.getRequest().getRequestURI().endsWith("devices"))
return null;
return new HttpStatusView(403);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:18,代码来源:ApiKeyFilter.java
示例4: test_view_render
import org.nutz.mvc.View; //导入依赖的package包/类
public void test_view_render() throws Throwable {
// 存入模板
loader.put("/hello", "${obj.array.~size},${obj.array[0]},${json(obj.user)}");
// 创建视图
View view = maker.make(null, "beetl", "/hello");
// 准备好返回值
Map<String, Object> map = new HashMap<String, Object>();
map.put("array", new String[]{"http://wendal.net"});
map.put("user", new NutMap().setv("name", "wendal"));
// 用于接收视图渲染的结果
ByteArrayOutputStream out = new ByteArrayOutputStream();
// mock出req和resp
HttpServletRequest req = mockReq(map);
HttpServletResponse resp = mockResp(out);
// 渲染
view.render(req, resp, map);
// 对比结果
assertEquals("1,http://wendal.net,{\"name\":\"wendal\"}", new String(out.toByteArray()));
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:26,代码来源:BeetlViewMakerTest.java
示例5: make
import org.nutz.mvc.View; //导入依赖的package包/类
@Override
public View make(Ioc ioc, String type, String value) {
if (VIEW_FREEMAKER.equals(type)) {
return new FreeMakerView(value);
}
return super.make(ioc, type, value);
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:8,代码来源:DDView.java
示例6: match
import org.nutz.mvc.View; //导入依赖的package包/类
@Override
public View match(ActionContext actionContext) {
HttpServletRequest request = actionContext.getRequest();
AuthenticationToken authenticationToken = createToken(request);
request.setAttribute("loginToken", authenticationToken);
return null;
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:8,代码来源:AuthenticationFilter.java
示例7: user
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/user")
@Ok("void")
public View user(@Param("username")String username, @Param("password")String password) {
log.infof("u=%s p=%s", username, password);;
if (Strings.isBlank(username))
return HTTP_403;
if (dao.count(IotUser.class, Cnd.where("name", "=", username).and("apikey", "=", password)) == 1) {
return null;
}
return HTTP_403;
}
开发者ID:wendal,项目名称:whale,代码行数:12,代码来源:MqttAuthModule.java
示例8: isSuperUser
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/super")
@Ok("void")
public View isSuperUser(@Param("username")String username) {
if ("admin".equals(username))
return null;
return HTTP_403;
}
开发者ID:wendal,项目名称:whale,代码行数:8,代码来源:MqttAuthModule.java
示例9: acl
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/acl")
@Ok("void")
@Fail("http:403")
public View acl(@Param("username")String username, @Param("topic")String topic, @Param("acc")String acc) {
if (!"1".equals(acc))
return HTTP_403; // TODO 支持mqtt发布, 即通过mqtt更新传感器的值
if (Strings.isBlank(topic) || !topic.matches("^iot2/sensor/[0-9]+$"))
return HTTP_403;
long sensor_id = Long.parseLong(topic.substring("iot2/sensor/".length()));
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("name", "=", username).and("id", "=", sensor_id));
if (sensor == null)
return HTTP_403;
return null;
}
开发者ID:wendal,项目名称:whale,代码行数:15,代码来源:MqttAuthModule.java
示例10: get_user
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/user")
@Ok("void")
public View get_user(@Param("username")String username, @Param("password")String password) {
log.infof("u=%s p=%s", username, password);;
if (Strings.isBlank(username))
return HTTP_403;
if (dao.count(IotUser.class, Cnd.where(Zs.UID, "=", userService.userId(username)).and("apikey", "=", password)) == 1)
return null;
return HTTP_403;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:11,代码来源:MqttAuthModule.java
示例11: isSuperUser
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/super")
@Ok("void")
public View isSuperUser(@Param("username")String username) {
if ("root".equals(username))
return null;
return HTTP_403;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:8,代码来源:MqttAuthModule.java
示例12: acl
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/acl")
@Ok("void")
public View acl(@Param("username")String username, @Param("topic")String topic, @Param("acc")String acc) {
if (!"1".equals(acc))
return HTTP_403; // TODO 支持mqtt发布, 即通过mqtt更新传感器的值
if (Strings.isBlank(topic) || !topic.matches("^iot/sensor/[0-9]+$"))
return HTTP_403;
long sensor_id = Long.parseLong(topic.substring("iot/sensor/".length()));
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where(Zs.UID, "=", userService.userId(username)).and("id", "=", sensor_id));
if (sensor == null)
return HTTP_403;
return null;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:14,代码来源:MqttAuthModule.java
示例13: index
import org.nutz.mvc.View; //导入依赖的package包/类
@At("/home")
public View index() {
HttpSession session = Mvcs.getHttpSession();
if (session.getAttribute("usr") == null)
return usrLogin;
return USER_HOME_PAGE;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:8,代码来源:MainModule.java
示例14: make
import org.nutz.mvc.View; //导入依赖的package包/类
/**
* @param ioc ioc容器
* @param type 类型
* @param value 值
* @return 视图
*/
public View make(Ioc ioc, String type, String value) {
if ("fm".equalsIgnoreCase(type)) {
return new FreemarkerView(value);
}
return null;
}
开发者ID:sunsetyan,项目名称:nutz_frame,代码行数:13,代码来源:FreemarkerViewMaker.java
示例15: make
import org.nutz.mvc.View; //导入依赖的package包/类
public View make(Ioc ioc, String type, String value) {
if (!"wx".equals(type))
return null;
return WxView.me;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:6,代码来源:WxViewMaker.java
示例16: msgIn
import org.nutz.mvc.View; //导入依赖的package包/类
@At({"/weixin", "/weixin/?"})
@Fail("http:200")
public View msgIn(String key, HttpServletRequest req) throws IOException {
return Wxs.handle(getWxHandler(key), req, key);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:6,代码来源:WxAbstractModule.java
示例17: jsonView
import org.nutz.mvc.View; //导入依赖的package包/类
protected View jsonView() {
if (DEBUG_MODE)
return UTF8JsonView.FULL;
return UTF8JsonView.COMPACT;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:6,代码来源:SmartView.java
示例18: make
import org.nutz.mvc.View; //导入依赖的package包/类
public View make(Ioc ioc, String type, String value) {
if ("smart".equals(type) || "*".equals(type))
return new SmartView(value);
return null;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:6,代码来源:SmartViewMaker.java
示例19: handle
import org.nutz.mvc.View; //导入依赖的package包/类
/**
* 用一个wxHandler处理对应的用户请求
*/
public static View handle(WxHandler wxHandler, HttpServletRequest req, String key)
throws IOException {
if (wxHandler == null) {
log.info("WxHandler is NULL");
return HttpStatusView.HTTP_502;
}
String signature = req.getParameter("signature");
String timestamp = req.getParameter("timestamp");
String nonce = req.getParameter("nonce");
String msg_signature = req.getParameter("msg_signature");
String encrypt_type = req.getParameter("encrypt_type");
if (!wxHandler.check(signature, timestamp, nonce, key)) {
log.info("token is invalid");
return HttpStatusView.HTTP_502;
}
if ("GET".equalsIgnoreCase(req.getMethod())) {
String echostr = req.getParameter("echostr");
log.info("GET? return echostr=" + echostr);
return new ViewWrapper(new RawView(null), echostr);
}
String postData = Streams.readAndClose(new InputStreamReader(req.getInputStream(),
Encoding.CHARSET_UTF8));
if ("aes".equals(encrypt_type)) {
WXBizMsgCrypt msgCrypt = wxHandler.getMsgCrypt();
try {
// 若抛出Illegal key size,请更新JDK的加密库为不限制长度
postData = msgCrypt.decryptMsg(msg_signature, timestamp, nonce, postData);
}
catch (AesException e) {
return new HttpStatusView(403);
}
}
WxInMsg in = Wxs.convert(postData);
in.setExtkey(key);
WxOutMsg out = wxHandler.handle(in);
if (out != null) {
Wxs.fix(in, out);
}
return new ViewWrapper(WxView.me, out);
}
开发者ID:nutzam,项目名称:nutzwx,代码行数:45,代码来源:Wxs.java
示例20: make
import org.nutz.mvc.View; //导入依赖的package包/类
public View make(Ioc ioc, String type, String value) {
if ("beetl".equals(type))
return new BeetlView(render, value);
return null;
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:6,代码来源:BeetlViewMaker.java
注:本文中的org.nutz.mvc.View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论