如何通过反射获取对象中的字段?(How to get the fields in an Object via reflection?)
我在Java中有一个对象(基本上是一个VO),我不知道它的类型。
我需要获取该对象不为null的值。如何才能做到这一点?
I have an object (basically a VO) in Java and I don't know its type.
I need to get values which are not null in that object.How can this be done?
原文:https://stackoverflow.com/questions/2989560
更新时间:2021-08-17 17:08
最满意答案
您可以像这样设置一个cookie:
cookies[:welcomed] = {:value => true, :expires => Time.now + 6.months}
并从jquery做一个小功能
function readCookie(name) { var nameEQ = name + "=", ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i += 1) { var c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; }
并称之为#in js
if (readCookie('welcomed') == null){}
You can set a cookie like this:
cookies[:welcomed] = {:value => true, :expires => Time.now + 6.months}
and from jquery make a wee function
function readCookie(name) { var nameEQ = name + "=", ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i += 1) { var c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; }
and call it #in js
if (readCookie('welcomed') == null){}
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
您可以像这样设置一个cookie: cookies[:welcomed] = {:value => true, :expires => Time.now + 6.months} 并从jquery做一个小功能 function readCookie(name) { var nameEQ = name + "=", ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i += 1) { var c = ...
-
获取用户访问的链接(Get user visited links)[2022-06-03]
使用Javascript从后台中的每个网址的主页请求图片,并在响应中提供时间。 如果图像被缓存,它几乎立即显示,表明该网站已被访问。 Use Javascript to request an image from the homepage of each URL in the background and time the response. It will be almost immediate if the image is cached, which indicates the site has be ... -
您的代码只会在第二次访问时将firstvisit设置为1。 这是因为isset($_COOKIE['firstvisit'])必须求值为true才能运行查询,并且cookie仅在下一个请求中可用 - setcookie()不会添加到$_COOKIE数组。 // assumes $_SESSION['uid'] is always set if(!isset($_COOKIE['firstvisit'])) { setcookie('firstvisit', time()); //set a coo ...
-
你可以在你的application_controller中放入这样的东西: class ApplicationController < ActionController::Base before_filter :store_history private def store_history session[:history] ||= [] session[:history].delete_at(0) if session[:history].size >= 5 sessi ...
-
制作一个中间件,然后通过它传递您的请求。 因此,无论何时您请求艺术路线,它都将从该中间件传递,在中间件中您可以为您的增量编写逻辑。 Make a middleware and then pass your requests through it. so whenever you request artical route it will be passed from that middleware and in middleware you can write logic for your incremen ...
-
如何知道单个用户在Google Analytics上访问了哪些网页?(How to know which pages a single user visited on Google Analytics?)[2022-07-15]
我能够通过转到内容>网站内容>所有页面并添加自定义细分(在高级细分中),使我能够按自定义变量(即我的用户ID)进行过滤。 这样它就会显示我已过滤的用户查看的所有页面 I was able to make it work by going to Content > Site Content > All Pages and adding a custom segment (in Advanced Segments) that allowed me to filter by custom variable (ie ... -
只需阅读localStorage并检查您是否已保存访问。 如果没有,请运行您的脚本(如我的示例中的alert )并将访问保存在localStorage 。 var ls = localStorage.getItem('namespace.visited'); if (ls == null) { alert("Your first visit"); localStorage.setItem('namespace.visited', 1) } http://jsfiddle.net/zgFgq ...
-
Android如何跟踪用户在浏览器中访问过的页面,(Android how to trace that the user visited the page in a browser,)[2022-01-04]
不,这是不可能的。 您是否希望任何第三方应用能够跟踪您在手机上浏览的内容? No, it's not possible. Would you want any third-party app to be able to track what you browse on your phone?