本文整理汇总了Java中org.nutz.mvc.Mvcs类的典型用法代码示例。如果您正苦于以下问题:Java Mvcs类的具体用法?Java Mvcs怎么用?Java Mvcs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mvcs类属于org.nutz.mvc包,在下文中一共展示了Mvcs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: make
import org.nutz.mvc.Mvcs; //导入依赖的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: getTemplateShareVars
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
/**
* 模板引擎共用的变量
*/
public static NutMap getTemplateShareVars() {
NutMap share = new NutMap();
Ioc ioc = Mvcs.getIoc();
share.put("ioc", ioc);
PropertiesProxy conf = ioc.get(PropertiesProxy.class, "conf");
share.put("conf", conf.toMap());
if (!conf.getBoolean("cdn.enable", false) || Strings.isBlank(conf.get("cdn.urlbase"))) {
share.put("cdnbase", "");
} else {
share.put("cdnbase", conf.get("cdn.urlbase"));
}
return share;
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:19,代码来源:Toolkit.java
示例3: upload
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@At({"/iot/device/?/sensor/?/datapoints", "/v1.1/device/?/sensor/?/datapoints"})
@POST
@AdaptBy(type=VoidAdaptor.class)
@Ok("void")
public void upload(String device_id, String sensor_id, InputStream in, @Attr(Zs.UID)long userId, HttpServletResponse resp) throws IOException {
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId).and("id", "=", sensor_id));
if (sensor == null) {
resp.setStatus(406);
resp.getWriter().write(Iots.NOTFOUND);
return;
}
if (sensor.getLastUpdateTime() != null && System.currentTimeMillis() - sensor.getLastUpdateTime().getTime() < Iots.Limit_Sensor_Update_Interval * 1000 ) {
resp.setStatus(406);
resp.getWriter().write(Iots.TOOFAST);
return ; // too fast
}
SensorUploadResult re = iotSensorService.upload(sensor, in);
if (re.err == null)
return;
resp.setStatus(406);
Mvcs.write(resp, re, JsonFormat.compact());
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:23,代码来源:IotExchangeModule.java
示例4: getIoc
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public Ioc getIoc(){
if(ioc == null){
ioc = Mvcs.getIoc();
}else if(ioc == null){
ioc = Mvcs.ctx().getDefaultIoc();
}
return ioc;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:9,代码来源:SocketServer.java
示例5: Accepter
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
/**
*
* @author tanyaowu
*/
public Accepter() {
handlers.addv(String.valueOf(Type.REQFRIEND),Mvcs.getIoc().get(ReqMessageHandler.class,"reqMessageHandler"));
handlers.addv(String.valueOf(Type.DELFRIEND),Mvcs.getIoc().get(DelFriendMessageHandler.class,"delFriendMessageHandler"));
handlers.addv(String.valueOf(Type.JOIN_GROUP_REQ),Mvcs.getIoc().get(JoinGroupMessageHandler.class,"joinGroupMessageHandler"));
handlers.addv(String.valueOf(Type.OUT_GROUP_REQ),Mvcs.getIoc().get(OutGroupMessageHandler.class,"outGroupMessageHandler"));
handlers.addv(String.valueOf(Type.P2P_REQ),Mvcs.getIoc().get(P2PMessageHandler.class,"p2PMessageHandler"));
handlers.addv(String.valueOf(Type.GROUP_MSG_REQ),Mvcs.getIoc().get(GroupMessageHandler.class,"groupMessageHandler"));
handlers.addv(String.valueOf(Type.LOGIN_REQ_MSG),Mvcs.getIoc().get(LoginMessageHandler.class,"loginMessageHandler"));
handlers.addv(String.valueOf(Type.OLD_MESSAGE_REQ_MSG),Mvcs.getIoc().get(OldMessageHandler.class,"oldMessageHandler"));
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:15,代码来源:Accepter.java
示例6: render
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public void render(HttpServletRequest req, HttpServletResponse resp,
Object obj) throws Exception {
String path = evalPath(req, obj);
String args = "";
if (path != null && path.contains("?")) { // 将参数部分分解出来
args = path.substring(path.indexOf('?'));
path = path.substring(0, path.indexOf('?'));
}
String ext = getExt();
// 空路径,采用默认规则
if (Strings.isBlank(path)) {
path = Mvcs.getRequestPath(req);
path = (path.startsWith("/") ? "" : "/")
+ Files.renameSuffix(path, ext);
}
// 绝对路径 : 以 '/' 开头的路径不增加 '/WEB-INF'
else if (path.charAt(0) == '/') {
if (!path.toLowerCase().endsWith(ext))
path += ext;
}
// 包名形式的路径
else {
path = path.replace('.', '/') + ext;
}
// 执行 Forward
path = path + args;
RequestDispatcher rd = req.getRequestDispatcher(path);
if (rd == null)
throw Lang.makeThrow("Fail to find Forward '%s'", path);
// Do rendering
rd.forward(req, resp);
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:35,代码来源:FreeMakerView.java
示例7: test
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@At
public Object test(){
NutMap nm = new NutMap();
String contextPath = Mvcs.getServletContext().getContextPath();
String realPath = Mvcs.getServletContext().getRealPath("/");
String parent = new File(realPath).getParent();
nm.setv("contextPath",contextPath);
nm.setv("realPath",realPath);
nm.setv("parent",parent);
return nm;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:12,代码来源:UploadModule.java
示例8: dao
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public Dao dao() {
if (dao == null) {
dao = Mvcs.ctx().getDefaultIoc().get(Dao.class, "dao");
return dao;
}
return dao;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:8,代码来源:SimpleAuthorizingRealm.java
示例9: dao
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
private Dao dao() {
if (null == dao) {
Ioc ioc = Mvcs.getIoc();
if (null == ioc)
ioc = Mvcs.ctx.getDefaultIoc();
dao = ioc.get(Dao.class);
}
return dao;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:10,代码来源:AuthenticationFilter.java
示例10: beforeMethod
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
PathMappingCache pathMappingCache = (PathMappingCache)objInst.getSkyWalkingDynamicField();
String requestURL = pathMappingCache.findPathMapping(method);
if (requestURL == null) {
At methodRequestMapping = method.getAnnotation(At.class);
if (methodRequestMapping.value().length > 0) {
requestURL = methodRequestMapping.value()[0];
} else {
requestURL = "";
}
pathMappingCache.addPathMapping(method, requestURL);
requestURL = pathMappingCache.findPathMapping(method);
}
HttpServletRequest request = Mvcs.getReq();
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(request.getHeader(next.getHeadKey()));
}
AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier);
Tags.URL.set(span, request.getRequestURL().toString());
Tags.HTTP.METHOD.set(span, request.getMethod());
span.setComponent(ComponentsDefine.NUTZ_MVC_ANNOTATION);
SpanLayer.asHttp(span);
}
开发者ID:apache,项目名称:incubator-skywalking,代码行数:30,代码来源:ActionMethodInterceptor.java
示例11: afterMethod
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
HttpServletResponse response = Mvcs.getResp();
AbstractSpan span = ContextManager.activeSpan();
if (response.getStatus() >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
}
ContextManager.stopSpan();
return ret;
}
开发者ID:apache,项目名称:incubator-skywalking,代码行数:14,代码来源:ActionMethodInterceptor.java
示例12: end
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public void end(Object ctx) {
try {
if (Mvcs.getReq().getRequestURI().endsWith(".json")) {
Mvcs.write((HttpServletResponse)ctx, list, JsonFormat.compact());
} else {
Writer writer = ((HttpServletResponse)ctx).getWriter();
for (NutMap map : list) {
writer.write(String.format("%s,%s\n", map.get("ok"), map.get("msg")));
}
}
} catch (IOException e) {
e.printStackTrace();//不常见
}
}
开发者ID:wendal,项目名称:whale,代码行数:15,代码来源:IotHttpCmdHandler.java
示例13: login
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@At
public boolean login(@Param("name")String name,
@Param("passwd")String password,
@Param("captcha")String captcha,
@Attr(value=Zs.UID)Long uid){
if (uid != null) {
return true;
}
if (name == null || password == null || captcha == null)
return false;
if (name.length() > 64 || password.length() > 64 || captcha.length() > 64)
return false;
HttpSession session = Mvcs.getHttpSession(false);
if (session == null) { // 直接调用login,没门!
return false;
}
Object _captcha = session.getAttribute(Toolkit.captcha_attr);
if (_captcha == null) //连验证码都没有咯,没门!
return false;
if (!Toolkit.checkCaptcha(_captcha.toString(), captcha)) {
Lang.sleep(1000); // 暂停1s再响应. TODO 容易导致DDOS
return false; // 验证码不过? 没门!
}
// TODO 下面是检查登录信息的逻辑,应当抽象为一个接口实现.
User usr = dao.fetch(User.class, Cnd.where("name", "=", name));
if (usr == null || !Toolkit.passwordEncode(password, usr.getSlat()).equals(usr.getPasswd())) {
Lang.sleep(1000); // 暂停1s再响应. TODO 容易导致DDOS
return false;
}
log.debug("User login success >> " + name);
// TODO 记录到系统操作日志中
session.setAttribute(Zs.UID, usr.getId()); // session里面只放id哦
return true;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:37,代码来源:UserModule.java
示例14: requirePasswdReset
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@At("/pwd_reset")
public boolean requirePasswdReset(@Param("name")String name,
@Param("email")String email,
@Param("captcha")String captcha) {
if (name == null || email == null || captcha == null)
return false;
if (name.length() > 64 || email.length() > 64 || captcha.length() > 64)
return false;
HttpSession session = Mvcs.getHttpSession(false);
if (session == null) { // 直接调用login,没门!
return false;
}
Object _captcha = session.getAttribute(Toolkit.captcha_attr);
if (_captcha == null) //连验证码都没有咯,没门!
return false;
if (!Toolkit.checkCaptcha(_captcha.toString(), captcha)) {
Lang.sleep(1000); // 暂停1s再响应. TODO 容易导致DDOS
return false; // 验证码不过? 没门!
}
User usr = dao.fetch(User.class, name);
if (usr == null || !email.equalsIgnoreCase(usr.getEmail())) {
log.debug("email not match");
return false;
}
String tpl = "URL: ${url}/callback/${token}";
Context ctx = Lang.context();
ctx.set("url", Mvcs.getReq().getRequestURL().toString());
String token = String.format("u=%s,t=%d,slat=%s", name, System.currentTimeMillis(), usr.getSlat());
token = Toolkit._3DES_encode(pwdResetKey, token.getBytes());
if (token == null)
return false;
ctx.set("token", token);
return mailService.send(usr.getEmail(), "Password reset", tpl, ctx);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:35,代码来源:UserModule.java
示例15: checkCaptcha
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
@At("/captcha/check")
public boolean checkCaptcha(@Param("answer")String answer) {
HttpSession session = Mvcs.getHttpSession(false);
if (session != null) {
Object text = session.getAttribute(answer);
if (text != null) {
if (Toolkit.checkCaptcha(text.toString(), answer))
return true;
}
// 当输入出错,强制要求重新生成新的验证码
//session.removeAttribute(captcha_attr);
}
return false;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:15,代码来源:ToolkitModule.java
示例16: addMP
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public void addMP(final WxMpInfo mp) {
if (mp == null || mp.getOpenid() == null)
return;
final Dao dao = ExtDaos.ext(this.dao, mp.getOpenid());
dao.create(WxMsgHistory.class, false);
dao.create(WxMsgStore.class, false);
masters.put(mp.getOpenid(), mp);
WxAPI api = new WxApiImpl(mp) {
public void reflushAccessToken() {
super.reflushAccessToken();
dao.update(mp, "^(access_token)");
}
@Override
public void send(WxOutMsg out) {
super.send(out);
wxHistory.push(out);
}
};
apis.put(mp.getOpenid(), api);
WxHandler handler = null;
if (Strings.isBlank(mp.getHandlerClass())) {
handler = new EnhandWxHandler();
} else {
try {
handler = (WxHandler) Mvcs.ctx().getDefaultIoc().get(Class.forName(mp.getHandlerClass()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (handler instanceof EnhandWxHandler)
((EnhandWxHandler)handler).setToken(mp.getToken());
handlers.put(mp.getOpenid(), handler);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:35,代码来源:NutDaoWxContext.java
示例17: index
import org.nutz.mvc.Mvcs; //导入依赖的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
示例18: render
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public void render(HttpServletRequest req, HttpServletResponse resp, Object obj) throws Throwable {
String child = evalPath(req, obj);
if (child == null) {
child = Mvcs.getActionContext().getPath();
}
if (obj != null && req.getAttribute("obj") == null)
req.setAttribute("obj", obj);
if (resp.getContentType() == null)
resp.setContentType("text/html");
render.render(child, req, new LazyResponseWrapper(resp));
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:BeetlView.java
示例19: BeetlViewMaker
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public BeetlViewMaker() throws IOException {
// 主动设置webroot, 解决maven项目下,Beetl无法找到正确的webapp路径的问题
String webroot = null;
if(Mvcs.getServletContext()!=null){
webroot = Mvcs.getServletContext().getRealPath("/");
if (!Strings.isBlank(webroot))
BeetlUtil.setWebroot(webroot);
}
init();
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:BeetlViewMaker.java
示例20: getDir
import org.nutz.mvc.Mvcs; //导入依赖的package包/类
public String getDir(){
String realPath = Mvcs.getServletContext().getRealPath("/");
String parent = new File(realPath).getParent();
log.debug("uploadDir:"+parent);
return parent;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:7,代码来源:UploadModule.java
注:本文中的org.nutz.mvc.Mvcs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论