问:
How to scale authorization for my resource management system
I have two systems

One Access management system where I store references of resources, users and access rights between them.

One Resource management system where I keep data about the resources and provide and an API to manage and query them.

When a request is received in the Resource management system, a query is sent to the Access management system to get a list of resource ids, to which the current user have access. This list is used as a criteria in the Resource Management PostgreSQL database when fetching data from it, so I only return results for data the user has access to.

This works fine in the small scale when a user have access up to a couple of hundred resources, but how do I scale this to work for users with access to 2000 or 20000 resources? I can't pass 20000 resource ids between my systems for every request!

答:
Your design seems to be the problem.

It is odd to separate objects and their access control in different systems. Apart from the inefficiencies you are experiencing, it will be difficult to keep the systems synchonized.

One proven method (that PostgreSQL uses) is to store the permissions on the objects themselves as an "access control list". Then you know if somebody may access an object or not without fetching additional data. Another advantage is that permissions are automatically removed with the object.


来源: stackexchange

问:
Can a JS script block a whole server? If so, how can I possibly get rid of this attack?
We are using MySQL db and Apache as our server. All of our project folders are affected by a particular script called "y.js/a.js" which is blocking our whole .js files and sits before  that triggers 404 error. The URL it all refers to is https://tom.verybeatifulantony.com/a.js (or) https://tom.verybeatifulantony.com/y.js. It calls this same js files in each and every project.

The following are the screenshots below:

答: Just remove the link and save it, i did the same and it works. </p>

ContentLicense: CC BY-SA 4.0


问:
How to fix error: TypeError: elements.classList is undefined?
I'm trying to add a class called "blackbackdrop" to every element that has a class called "icon" using classList.
Unfortunately it does not work because of error TypeError: elements.classList is undefined

I'm using this code:

function blackBackDropIcon() {
  var elements = document.getElementsByClassName("icon");
  elements.classList.add('blackbackdrop');
}
```

答:
it returns array so you need to add the class via loop all elements of the array and add one by one.

here is code...

```<code>function blackBackDropIcon() {
        var elements = document.getElementsByClassName("icon");
        for (a = 0; a < elements.length; a++) {
            elements[a].classList.add('blackbackdrop');
        }
    }
</code>```

Explanation:
You Can't give all elements array class directly you can give it via array.

Body:
it returns array so you need to add the class via loop all elements of the array and add one by one.

here is code...

function blackBackDropIcon() {
        var elements = document.getElementsByClassName("icon");
        for (a = 0; a < elements.length; a++) {
            elements[a].classList.add('blackbackdrop');
        }
    }

Explanation:
You Can't give all elements array class directly you can give it via array.


问:
Can I execute script from json file
Can I execute script from json file?
For example:

```<code>helloworld.json
{
"script" : "console.log('helloworld');"
}
</code>```

I want to run the script in the json file in my html or js file.

答:
Point eval to the string to execute it as code

```<code>var json = {"script":"console.log('helloworld');"}
eval(json["script"])
</code>```

Also see Execute JavaScript code stored as a string

Title: Can I execute script from json file

Body:
Can I execute script from json file?
For example:

helloworld.json
{
"script" : "console.log('helloworld');"
}

I want to run the script in the json file in my html or js file.

Body:
Point eval to the string to execute it as code

var json = {"script":"console.log('helloworld');"}
eval(json["script"])

Also see Execute JavaScript code stored as a string


问:
Does redo logs store all the changes applied to database buffer cache?
I know that the redo log entries are created when there is insert/update/delete/create/drop/alter occurs. What information gets stored in redo log ? In case of instance failure, redo log file is used to recover database, does it contain information on changes applied database buffer cache?</p>

答:
If one does redo log mining (to view exactly what is in the redo logs), there is a view that tells you what they store: V$LOGMNR_CONTENTS.

This typically shows:

```<code>- Operation: INSERT, UPDATE, DELETE, or DDL
- SCN - system change number - very important for recovery
- The transaction to which a change belongs
- The table and schema name of the modified object
- The name of the user who issued the DDL or DML
- the SQL needed to redo and/or undo your changes.
</code>```

So yes, the redo logs contain changes made when dirty buffers are committed.  They are used to reconstruct the database in the case of failure.  They also protect rollback data, as the SQL both for redo and undo are stored and are played back during recovery.

V$LOG and V$LOGFILE show how your redo data files are allocated.  You would generally want them in pairs, as you have a backup in case one is lost. You also want to have at least 3 groups (pairs) as some are active, some are current, and some are being written to the archive logs which are also critical for recovery.

Body:
If one does redo log mining (to view exactly what is in the redo logs), there is a view that tells you what they store: V$LOGMNR_CONTENTS.

This typically shows:

- Operation: INSERT, UPDATE, DELETE, or DDL
- SCN - system change number - very important for recovery
- The transaction to which a change belongs
- The table and schema name of the modified object
- The name of the user who issued the DDL or DML
- the SQL needed to redo and/or undo your changes.

So yes, the redo logs contain changes made when dirty buffers are committed.  They are used to reconstruct the database in the case of failure.  They also protect rollback data, as the SQL both for redo and undo are stored and are played back during recovery.

V$LOG and V$LOGFILE show how your redo data files are allocated.  You would generally want them in pairs, as you have a backup in case one is lost. You also want to have at least 3 groups (pairs) as some are active, some are current, and some are being written to the archive logs which are also critical for recovery.


问:
iphone : problem while fetching tweets from twitter
In my iphone app, I am trying to fetch tweets from twitter.

And I got one example coding from following link :

https://github.com/mattgemmell/MGTwitterEngine

But when i implemented this example I got following warning:

```<code>Ld build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo normal i386
 cd "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo"
  setenv MACOSX_DEPLOYMENT_TARGET 10.6
 setenv PATH      "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/Libraries & Headers/OAuthConsumer" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo" "-F/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" -filelist "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/XAuthTwitterEngineDemo.build/Debug-iphonesimulator/XAuthTwitterEngineDemo.build/Objects-normal/i386/XAuthTwitterEngineDemo.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -lOAuth -lsqlite3 -lxml2 -o "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo"

ld: in /Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/libxml2.dylib, file too small
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
</code>```

What can be done?

答: You can fetch tweets from this url and it returns xml from which you can parse tweets.

ContentLicense: CC BY-SA 3.0

Body:
In my iphone app, I am trying to fetch tweets from twitter.

And I got one example coding from following link :

https://github.com/mattgemmell/MGTwitterEngine

But when i implemented this example I got following warning:

Ld build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo normal i386
 cd "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo"
  setenv MACOSX_DEPLOYMENT_TARGET 10.6
 setenv PATH      "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/Libraries & Headers/OAuthConsumer" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo" "-F/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" -filelist "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/XAuthTwitterEngineDemo.build/Debug-iphonesimulator/XAuthTwitterEngineDemo.build/Objects-normal/i386/XAuthTwitterEngineDemo.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -lOAuth -lsqlite3 -lxml2 -o "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo"

ld: in /Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/libxml2.dylib, file too small
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

What can be done?


问:
MySQL Query error using UNION/UNION ALL and Group By
Generate the following two result sets:

1). Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).

2). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:

There are total [occupation_count] [occupation]s.

Table Name: Occupations

Total Columns: Two = 'Name' and 'Occupation', demo table is shown below:

Sample Output:

```<code>Ashely(P)
Christeen(P)
Jane(A)
Jenny(D)
Julia(A)
Ketty(P)
Maria(A)
Meera(S)
Priya(S)
Samantha(D)
There are total 2 doctors.
There are total 2 singers.
There are total 3 actors.
There are total 3 professors.
</code>```

My Approach:

```<code>(SELECT NAME, '(', SUBSTRING(OCCUPATION, 1, 1), ')'
    FROM OCCUPATIONS ORDER BY NAME)
UNION ALL
(SELECT COUNT(*) FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY ASEC);
</code>```

Error:

```<code>ERROR 1222 (21000) at line 1:
    The used SELECT statements have a different number of columns
</code>```

Thank You!

答:
check below code. hope this helps its 100% working

select concat(Name,"(",left(Occupation,1),")")
  from occupations
 order by Name;

select concat("There are a total of ",count(Occupation),' ',lower(occupation),"s.")
  from Occupations
 group by occupation
 order by count(Occupation)asc, Occupation;
```

Body:
Generate the following two result sets:

1). Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).

2). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:

There are total [occupation_count] [occupation]s.

Table Name: Occupations

Total Columns: Two = 'Name' and 'Occupation', demo table is shown below:

Sample Output:

Ashely(P)
Christeen(P)
Jane(A)
Jenny(D)
Julia(A)
Ketty(P)
Maria(A)
Meera(S)
Priya(S)
Samantha(D)
There are total 2 doctors.
There are total 2 singers.
There are total 3 actors.
There are total 3 professors.

My Approach:

(SELECT NAME, '(', SUBSTRING(OCCUPATION, 1, 1), ')'
    FROM OCCUPATIONS ORDER BY NAME)
UNION ALL
(SELECT COUNT(*) FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY ASEC);

Error:

ERROR 1222 (21000) at line 1:
    The used SELECT statements have a different number of columns

Thank You!


问:
How do i load google fonts on the sever side node js
I am using node js and canvas to create an API that writes text on a certain image. I successfully created a route such as -> /:sometext/:fontsize/:color/:position-x/:position-y and sends a static image with the text of the given font-size, color, and position on the canvas.

What I am unable to achieve is that I want to send the font family in the route and have that rendered on the screen. Plus, isn't there any other way that I can load at least google fonts without having to download the .ttf file.

What I have tried:

GetGoogleFonts npm package (which was a bad idea, since it was stuck at the installation)

WebFontLoader (Gives "Window is not defined" error)

Steps to Reproduce

Currently, I am using a ttf file to load the font

```<code>
router.get('/thumbnail/:name/:fontsize/:color/:posx/:posy', function (req, res, next) {
  let name = req.params.name;
  let fontsize = req.params.fontsize
  let positionx = req.params.posx
  let positiony = req.params.posy
  let color = req.params.color

  let myimage = 'static/image1.jpg'

  const canvas = createCanvas(2000, 1000)
  const ctx = canvas.getContext('2d')
  var str = "hi "+name
  registerFont('AvenirNext.ttf', { family: 'Avenir Next' })
  loadImage(myimage).then((image) => {
  ctx.drawImage(image, 0 , 0, 2000, 1000);
  ctx.font = fontsize + "px Avenir Next"
  ctx.fillStyle = color
  ctx.fillText(str, positionx, positiony);

  const out = fs.createWriteStream(__dirname + '/test.jpeg')
  const stream = canvas.createJPEGStream()
  stream.pipe(res)
  out.on('finish', () =>  console.log('The JPEG file was created.'))

})
});

</code>```

答:
From the docs for registerFont

To use a font file that is not installed as a system font, use registerFont() to register the font with Canvas. This must be done before the Canvas is created.

emphasis not mine

You are calling it after you created your canvas.

```<code>// first register the font
registerFont('AvenirNext.ttf', { family: 'Avenir Next' });
// then create the canvas
const canvas = createCanvas(2000, 1000);
const ctx = canvas.getContext('2d');
var str = "hi " + name;
</code>```

But note that this will try to load a font that would be available on your server. If you want to make it target a font on ://fonts.googleapis.com server, you'd need to pass the full URI to the font file (not for the .css).

Also, you should wrap your family name inside quotes (") since it contains a space:

```<code>ctx.font = fontsize + 'px "Avenir Next"';
</code>```

Body:
I am using node js and canvas to create an API that writes text on a certain image. I successfully created a route such as -> /:sometext/:fontsize/:color/:position-x/:position-y and sends a static image with the text of the given font-size, color, and position on the canvas.

What I am unable to achieve is that I want to send the font family in the route and have that rendered on the screen. Plus, isn't there any other way that I can load at least google fonts without having to download the .ttf file.

What I have tried:

GetGoogleFonts npm package (which was a bad idea, since it was stuck at the installation)

WebFontLoader (Gives "Window is not defined" error)

Steps to Reproduce

Currently, I am using a ttf file to load the font

router.get('/thumbnail/:name/:fontsize/:color/:posx/:posy', function (req, res, next) {
  let name = req.params.name;
  let fontsize = req.params.fontsize
  let positionx = req.params.posx
  let positiony = req.params.posy
  let color = req.params.color

  let myimage = 'static/image1.jpg'

  const canvas = createCanvas(2000, 1000)
  const ctx = canvas.getContext('2d')
  var str = "hi "+name
  registerFont('AvenirNext.ttf', { family: 'Avenir Next' })
  loadImage(myimage).then((image) => {
  ctx.drawImage(image, 0 , 0, 2000, 1000);
  ctx.font = fontsize + "px Avenir Next"
  ctx.fillStyle = color
  ctx.fillText(str, positionx, positiony);

  const out = fs.createWriteStream(__dirname + '/test.jpeg')
  const stream = canvas.createJPEGStream()
  stream.pipe(res)
  out.on('finish', () =>  console.log('The JPEG file was created.'))

})
});

Body:
From the docs for registerFont

To use a font file that is not installed as a system font, use registerFont() to register the font with Canvas. This must be done before the Canvas is created.

emphasis not mine

You are calling it after you created your canvas.

// first register the font
registerFont('AvenirNext.ttf', { family: 'Avenir Next' });
// then create the canvas
const canvas = createCanvas(2000, 1000);
const ctx = canvas.getContext('2d');
var str = "hi " + name;

But note that this will try to load a font that would be available on your server. If you want to make it target a font on ://fonts.googleapis.com server, you'd need to pass the full URI to the font file (not for the .css).

Also, you should wrap your family name inside quotes (") since it contains a space:

ctx.font = fontsize + 'px "Avenir Next"';


问:
To develop the ui on Spring Boot Admin Server
I would like to do some personalized development on spring-boot-admin-server-ui.According to README prompt,my configuration file is as follows:

```<code>spring:
 boot:
  admin:
   ui:
    cache:
     no-cache: true
    resource-locations: file://D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
    template-location: file://D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
    cache-templates: false
</code>```

I'm sure the file path is correct and the execution of the "npm run watch" was also successful.
But always has an error as follows:

```<code>2020-02-17 21:40:41.249 ERROR 13216 --- [nio-8766-exec-8] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8766-exec-8] Exception processing template "login": An error happened during template parsing (template: "URL [file://D:/WorkSpace/UseIDEA/GIT/ai-[...]i/target/dist/login.html]")

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "URL [file://D:/WorkSpace/UseIDEA/GIT/ai-[...]i/target/dist/login.html]")
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:235) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:354) [thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187) [thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.1.10.jar:1.1.10]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:155) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:123) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_212]
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_212]
    at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:962) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:924) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1019) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1005) ~[na:1.8.0_212]
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:294) ~[na:1.8.0_212]
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:400) ~[na:1.8.0_212]
    at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:171) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.thymeleaf.spring5.templateresource.SpringResourceTemplateResource.reader(SpringResourceTemplateResource.java:103) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:223) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    ... 100 common frames omitted

</code>```

Please give me some help,Thank you!

答:
Thanks for Eugene Kortov's help,i found a solution of this problem.i cloned spirng-boot-admin of version 2.0.2 and according to README of this version.but when i change the configuration item according to the latest version's README:

```<code>resource-locations: file:D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
template-location: file:D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
</code>```

problem solved.Although i'm sure the version of the code has not changed.I haven't looked at the source code, but it is really an inexplicable error.

Body:
I would like to do some personalized development on spring-boot-admin-server-ui.According to README prompt,my configuration file is as follows:

spring:
 boot:
  admin:
   ui:
    cache:
     no-cache: true
    resource-locations: file://D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
    template-location: file://D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
    cache-templates: false

I'm sure the file path is correct and the execution of the "npm run watch" was also successful.
But always has an error as follows:

2020-02-17 21:40:41.249 ERROR 13216 --- [nio-8766-exec-8] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8766-exec-8] Exception processing template "login": An error happened during template parsing (template: "URL [file://D:/WorkSpace/UseIDEA/GIT/ai-[...]i/target/dist/login.html]")

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "URL [file://D:/WorkSpace/UseIDEA/GIT/ai-[...]i/target/dist/login.html]")
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:235) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:354) [thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187) [thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) [spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.1.10.jar:1.1.10]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) [spring-security-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:155) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:123) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108) [spring-boot-actuator-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.32.jar:8.5.32]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_212]
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_212]
    at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:962) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:924) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1019) ~[na:1.8.0_212]
    at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1005) ~[na:1.8.0_212]
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:294) ~[na:1.8.0_212]
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:400) ~[na:1.8.0_212]
    at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:171) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.thymeleaf.spring5.templateresource.SpringResourceTemplateResource.reader(SpringResourceTemplateResource.java:103) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:223) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    ... 100 common frames omitted

Please give me some help,Thank you!

Body:
Thanks for Eugene Kortov's help,i found a solution of this problem.i cloned spirng-boot-admin of version 2.0.2 and according to README of this version.but when i change the configuration item according to the latest version's README:

resource-locations: file:D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/
template-location: file:D:/WorkSpace/UseIDEA/GIT/ai-server/springbootadmin/spring-boot-admin-server-ui/target/dist/

problem solved.Although i'm sure the version of the code has not changed.I haven't looked at the source code, but it is really an inexplicable error.


问:
unrecognized selector sent to instance obj c
2020-02-17 23:12:31.949254+0100 LoyaltyCardsApp[64133:7104122] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OTPViewController OTPPinInserted:pin:]: unrecognized selector sent to instance 0x7fd00a127730'

```<code>    @protocol OTPViewControllerDelegate
- (void) OTPAbortedByUser;
- (void) OTPPinInserted: (NSString *) pan pin: (NSString *) pin;

@end

@interface OTPViewController : UIViewController<KeyboardDelegate>

@property (nonatomic, strong) id delegate;

@property (nonatomic, weak) IBOutlet UIButton *confirmButton;
@property (weak, nonatomic) IBOutlet InputTextView *insertOTP;
@property (nonatomic, strong) NSString* stringInserted;
@property (weak, nonatomic) IBOutlet CopyableTextView *result;

@property (nonatomic, weak) IBOutlet NSLayoutConstraint *marginTop;

- (IBAction) clickOnDoneButton:(id)sender;
@end

- (void) pinInserted:(NSString *) pin{

    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];
</code>```

the crash occurs here:

```<code>    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];
</code>```

other thing, I can't understand why in debug I can't go inside the if ..

```<code>if (self.delegate && [self.delegate respondsToSelector:@selector(OTPPinInserted:pin:)]){
    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];
}
</code>```

答:
It is because you haven't implemented the OTPViewController protocol on the OTPViewController.

Or, more specifically, you need to implement this method:

```<code>- (void) OTPPinInserted: (NSString *) pan pin: (NSString *) pin;
</code>```

(or spell it right if you did implement it. :).

Note that having capital letters prefixed on the method name is a little odd.

I'd stick with -pinInserted:pin:.  If you have conflicting method declarations that typically indicates a different design problem.

If you do go the prefix route, then make it lowercase;  -otpPinInserted:pin:.

Body:
2020-02-17 23:12:31.949254+0100 LoyaltyCardsApp[64133:7104122] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OTPViewController OTPPinInserted:pin:]: unrecognized selector sent to instance 0x7fd00a127730'

    @protocol OTPViewControllerDelegate
- (void) OTPAbortedByUser;
- (void) OTPPinInserted: (NSString *) pan pin: (NSString *) pin;

@end

@interface OTPViewController : UIViewController<KeyboardDelegate>

@property (nonatomic, strong) id delegate;

@property (nonatomic, weak) IBOutlet UIButton *confirmButton;
@property (weak, nonatomic) IBOutlet InputTextView *insertOTP;
@property (nonatomic, strong) NSString* stringInserted;
@property (weak, nonatomic) IBOutlet CopyableTextView *result;

@property (nonatomic, weak) IBOutlet NSLayoutConstraint *marginTop;

- (IBAction) clickOnDoneButton:(id)sender;
@end

- (void) pinInserted:(NSString *) pin{

    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];

the crash occurs here:

    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];

other thing, I can't understand why in debug I can't go inside the if ..

if (self.delegate && [self.delegate respondsToSelector:@selector(OTPPinInserted:pin:)]){
    [self.delegate OTPPinInserted:self.insertOTP.input.text pin:pin];
}

Body:
It is because you haven't implemented the OTPViewController protocol on the OTPViewController.

Or, more specifically, you need to implement this method:

- (void) OTPPinInserted: (NSString *) pan pin: (NSString *) pin;

(or spell it right if you did implement it. :).

Note that having capital letters prefixed on the method name is a little odd.

I'd stick with -pinInserted:pin:.  If you have conflicting method declarations that typically indicates a different design problem.

If you do go the prefix route, then make it lowercase;  -otpPinInserted:pin:.


问:
How to get byte[] from float number
How to get byte[] from float number? I need to create message where for data I have four bytes, datum can be unsigned int( it is easy to get byte[] from int), binary and float ( but I don't know how to get four bytes from float ). Any solution ?</p>

答:
If you think it's easy getting the bytes of an int, Float.floatToIntBits is probably what you want:

```<code>float f = ...;
int i = Float.floatToIntBits(f);
byte[] floatBytes = toBytes(i);
</code>```

Title: How to get byte[] from float number

Body:
If you think it's easy getting the bytes of an int, Float.floatToIntBits is probably what you want:

float f = ...;
int i = Float.floatToIntBits(f);
byte[] floatBytes = toBytes(i);


问:
React navigation drawer v5x useNavigation() with Component Class
I have tried many times to navigate using useNavigation() in my Component class. But I couldn't because according to the error I should use this method inside of a body function. I tried it inside render() method. It wasn't also helpful. Could you possibly help me if anyone knows?

```<code>import { useNavigation } from '@react-navigation/native';

export default class MenuDrawer extends React.Component{

render(){

const  navigation  = useNavigation();
return(
    <View>
       <Button  onPress={()=>{navigation.navigate('detail')}}  />
   </View>
);

}
}
</code>```

答:
According to the docs here, you can wrap the component inside a function to use it

```<code>import { useNavigation } from '@react-navigation/native';

export default yourFunction(props) {
  const navigation = useNavigation();

  return <MenuDrawer navigation={navigation} />;
}
</code>```

Your new MenuDrawer

```<code>export default class MenuDrawer extends React.Component {
  render(){
    const { navigation } = this.props;
      return(
        <View>
         <Button onPress={()=>{navigation.navigate('detail')}}  />
       </View>
    );
  }
}
</code>```

Body:
I have tried many times to navigate using useNavigation() in my Component class. But I couldn't because according to the error I should use this method inside of a body function. I tried it inside render() method. It wasn't also helpful. Could you possibly help me if anyone knows?

import { useNavigation } from '@react-navigation/native';

export default class MenuDrawer extends React.Component{

render(){

const  navigation  = useNavigation();
return(
    <View>
       <Button  onPress={()=>{navigation.navigate('detail')}}  />
   </View>
);

}
}

Body:
According to the docs here, you can wrap the component inside a function to use it

import { useNavigation } from '@react-navigation/native';

export default yourFunction(props) {
  const navigation = useNavigation();

  return <MenuDrawer navigation={navigation} />;
}

Your new MenuDrawer

export default class MenuDrawer extends React.Component {
  render(){
    const { navigation } = this.props;
      return(
        <View>
         <Button onPress={()=>{navigation.navigate('detail')}}  />
       </View>
    );
  }
}


问:
How to set default marker position in google map api
I am using google map API I want to set default lat and long in marker. I have a location I want to open that location by default when map is loaded then it should be opened as the set location. How could I achieve this?</p>

答:
Write this in your mapReady function</p>

```<code>    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // enter the latitude and longitude in place of -35,151 respectively
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
</code>```

Body:
Write this in your mapReady function

    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // enter the latitude and longitude in place of -35,151 respectively
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}


问:
Dynamic object property javascript
is there a syntax with javascript es6 or es-next to achieve the following behavior

```<code>let t = {
    text: 'hello world',
    [shouldShow ? ...{'show' : 'test text'} : ''],
    test: 21
}
</code>```

I want that if shouldShow is true the object t should be

```<code>{
    text: 'hello world',
    show: 'test text',
    test: 21
}
</code>```

and if shouldShow is false the object t will be

```<code>{
    text: 'hello world',
    test: 21
}
</code>```

I know, I can do that with if/else but I'm asking if there is a syntax that I can use for just one line of code

答:
Hopefully this would solve :

In case you want the show property to be there when shouldShow is false, try this:

```<code>// this would give show:"" when shouldShow is false, else it will give show="test text"
let shouldShow = false;
let t = {
  text: "hello world",
  show: shouldShow ? "test text" : "",
  test: 21
};

</code>```

In case you want it to be removed from the object itself then try this,

```<code>// this would make show="test text" when shouldShow is true else remove it from "t"
let shouldShow = true;
let t = {
  text: "hello world",
  test: 21
};
t = shouldShow ? { ...t, show: "test text" } : t;

</code>```

Title: Dynamic object property javascript

Body:
is there a syntax with javascript es6 or es-next to achieve the following behavior

let t = {
    text: 'hello world',
    [shouldShow ? ...{'show' : 'test text'} : ''],
    test: 21
}

I want that if shouldShow is true the object t should be

{
    text: 'hello world',
    show: 'test text',
    test: 21
}

and if shouldShow is false the object t will be

{
    text: 'hello world',
    test: 21
}

I know, I can do that with if/else but I'm asking if there is a syntax that I can use for just one line of code

Body:
Hopefully this would solve :

In case you want the show property to be there when shouldShow is false, try this:

// this would give show:"" when shouldShow is false, else it will give show="test text"
let shouldShow = false;
let t = {
  text: "hello world",
  show: shouldShow ? "test text" : "",
  test: 21
};

In case you want it to be removed from the object itself then try this,

// this would make show="test text" when shouldShow is true else remove it from "t"
let shouldShow = true;
let t = {
  text: "hello world",
  test: 21
};
t = shouldShow ? { ...t, show: "test text" } : t;


问:
How to get name of variable
I have simple question.
How to get name of variable time from this example:

```<code>let x = {
  color: string = red;
}

let y = getVarName(x.color);
console.log(y);
</code>```

Result: color

How i can get this result above? getVarName is example function which i want to make.

答:
If i got your question.In typescript you can do something like this if you really want to get it by a function. Else you can simply get it by x.color

```<code>  let x = {
  color : 'red',
  getColor : function(){
    return this.color
  }
}

let y = x.getColor();
console.log(y); // output red
</code>```

working example

https://stackblitz.com/edit/typescript-73dpve?embed=1&file=index.ts

If you want key name than try this

```<code>let keys = Object.keys(x).filter(k=>x[k]==='red');

console.log(keys[0]) // output color
</code>```

Read about Object.keys() from js documentation

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

Title: How to get name of variable

Body:
I have simple question.
How to get name of variable time from this example:

let x = {
  color: string = red;
}

let y = getVarName(x.color);
console.log(y);

Result: color

How i can get this result above? getVarName is example function which i want to make.

Body:
If i got your question.In typescript you can do something like this if you really want to get it by a function. Else you can simply get it by x.color

  let x = {
  color : 'red',
  getColor : function(){
    return this.color
  }
}

let y = x.getColor();
console.log(y); // output red

working example

https://stackblitz.com/edit/typescript-73dpve?embed=1&file=index.ts

If you want key name than try this

let keys = Object.keys(x).filter(k=>x[k]==='red');

console.log(keys[0]) // output color

Read about Object.keys() from js documentation

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys


问:
django - why is this custom middleware not working
I am building a website using django 1.10. I have written a middleware class to restrict the number of page views for users that are not logged in. I implemented this functionality into a separate application 'pagerestrict'

settings.py [Relevant Entries]

```<code># Application definition

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',

        'django.contrib.sites',

        'pagerestrict.apps.PagerestrictConfig',
        # ...
    ]

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',

        'pagerestrict.middleware.CheckPageAccessMiddleware',
    ]
</code>```

Middleware code (middleware.py):

```<code>from django.http import HttpResponseRedirect
from decouple import config

class CheckPageAccessMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.get_response(request)

    def process_request(self, request):
        if not request.user.is_authenticated():
            current_page_url = request.path_info.lstrip('/')

            ignore_list = config('PAGE_RESTRICT_PAGE_IGNORES', cast=lambda v: [s.strip() for s in v.split(',')])

            #if not current_page_url or not any(current_page_url != url for url in ignore_list):
            if not current_page_url in ignore_list:
                # first things first ...
                if not has_attr(request, 'pages_visited'):
                    request.pages_visited = set()

                if not has_attr(request, 'page_count'):
                    request.page_count = 0

                if current_page_url not in request.pages_visited:
                    request.pages_visited.add(current_page_url)

                request.page_count += 1

                if request.page_count > config('PAGE_RESTRICT_PAGE_LIMIT'):
                    return HttpResponseRedirect(config('PAGE_RESTRICT_REDIRECT_URL'))
</code>```

I tested this by going to my homepage and refreshing the browser several times - the code never seemed to be triggered. What am I missing?

答:
Here is an example to show how to update the middleware when migrating to

Django ver > 1.10:
Upgrading pre-Django 1.10-style middleware

If it does not work:

You should also temporarily remove all default MIDDLEWARE class,

keeping only your custom MIDDLEWARE to make sure the previous
layers(default MIDDLEWARE) did not break the flow:

MIDDLEWARE = (
    # 'django.middleware.common.CommonMiddleware',
    'app.middleware.MyMiddlewareClass',
)
```

<ul>
<li>If you remove <code>django.middleware.common.CommonMiddleware</code> then it works. That could be <code>ALLOWED_HOSTS</code> problem. </li>
</ul>

<pre class="lang-py prettyprint-override"><code>- Replace
ALLOWED_HOSTS= ['localhost:8001']
- With
ALLOWED_HOSTS= ['localhost']
</code>```

Body:
I am building a website using django 1.10. I have written a middleware class to restrict the number of page views for users that are not logged in. I implemented this functionality into a separate application 'pagerestrict'

settings.py [Relevant Entries]

# Application definition

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',

        'django.contrib.sites',

        'pagerestrict.apps.PagerestrictConfig',
        # ...
    ]

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',

        'pagerestrict.middleware.CheckPageAccessMiddleware',
    ]

Middleware code (middleware.py):

from django.http import HttpResponseRedirect
from decouple import config

class CheckPageAccessMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.get_response(request)

    def process_request(self, request):
        if not request.user.is_authenticated():
            current_page_url = request.path_info.lstrip('/')

            ignore_list = config('PAGE_RESTRICT_PAGE_IGNORES', cast=lambda v: [s.strip() for s in v.split(',')])

            #if not current_page_url or not any(current_page_url != url for url in ignore_list):
            if not current_page_url in ignore_list:
                # first things first ...
                if not has_attr(request, 'pages_visited'):
                    request.pages_visited = set()

                if not has_attr(request, 'page_count'):
                    request.page_count = 0

                if current_page_url not in request.pages_visited:
                    request.pages_visited.add(current_page_url)

                request.page_count += 1

                if request.page_count > config('PAGE_RESTRICT_PAGE_LIMIT'):
                    return HttpResponseRedirect(config('PAGE_RESTRICT_REDIRECT_URL'))

I tested this by going to my homepage and refreshing the browser several times - the code never seemed to be triggered. What am I missing?

Body:
Here is an example to show how to update the middleware when migrating to

Django ver > 1.10:
Upgrading pre-Django 1.10-style middleware

If it does not work:

You should also temporarily remove all default MIDDLEWARE class,

keeping only your custom MIDDLEWARE to make sure the previous
layers(default MIDDLEWARE) did not break the flow:

MIDDLEWARE = (
    # 'django.middleware.common.CommonMiddleware',
    'app.middleware.MyMiddlewareClass',
)

If you remove django.middleware.common.CommonMiddleware then it works. That could be ALLOWED_HOSTS problem.

- Replace
ALLOWED_HOSTS= ['localhost:8001']
- With
ALLOWED_HOSTS= ['localhost']


答:
Yes, you have to:

Load your json file

Execute the script using eval()

Whether that's a good idea or not though depends on your specific use case.

Title: Can I execute script from json file

Body:
Can I execute script from json file?
For example:

helloworld.json
{
"script" : "console.log('helloworld');"
}

I want to run the script in the json file in my html or js file.


答:
You can use Float.floatToRawIntBits(float) but I suspect you don't need byte[] but instead want to be able to write to a stream of bytes. In which case I would use DataOutputStream.writeFloat(float)

If you are using NIO, you can use ByteBuffer.putFloat()  An advantage of ByteBuffer is that you can specify a ByteOrder with ByteBuffer.order() so you can handle either Big or Little endian.

Title: How to get byte[] from float number

Body: How to get byte[] from float number? I need to create message where for data I have four bytes, datum can be unsigned int( it is easy to get byte[] from int), binary and float ( but I don't know how to get four bytes from float ). Any solution ?


问:
getting the screen density programmatically in android?
How to get the screen density programmatically in android?

I mean: How to find the screen dpi of the current device?

答:
In Android you can get the screen density like this:

```<code>public static String getScreenDensity(Context context)
{
    String density;
    switch (context.getResources().getDisplayMetrics().densityDpi)
    {
        case DisplayMetrics.DENSITY_LOW:
            density = "LDPI";
            break;
        case DisplayMetrics.DENSITY_140:
            density = "LDPI - MDPI";
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            density = "MDPI";
            break;
        case DisplayMetrics.DENSITY_180:
        case DisplayMetrics.DENSITY_200:
        case DisplayMetrics.DENSITY_220:
            density = "MDPI - HDPI";
            break;
        case DisplayMetrics.DENSITY_HIGH:
            density = "HDPI";
            break;
        case DisplayMetrics.DENSITY_260:
        case DisplayMetrics.DENSITY_280:
        case DisplayMetrics.DENSITY_300:
            density = "HDPI - XHDPI";
            break;
        case DisplayMetrics.DENSITY_XHIGH:
            density = "XHDPI";
            break;
        case DisplayMetrics.DENSITY_340:
        case DisplayMetrics.DENSITY_360:
        case DisplayMetrics.DENSITY_400:
        case DisplayMetrics.DENSITY_420:
        case DisplayMetrics.DENSITY_440:
            density = "XHDPI - XXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXHIGH:
            density = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_560:
        case DisplayMetrics.DENSITY_600:
            density = "XXHDPI - XXXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXXHIGH:
            density = "XXXHDPI";
            break;
        case DisplayMetrics.DENSITY_TV:
            density = "TVDPI";
            break;
        default:
            density = "UNKNOWN";
            break;
    }

    return density;
}
</code>```

And in Kotlin like this:

```<code>fun getScreenDensity(context: Context): String {
    val density: String
    when (context.resources.displayMetrics.densityDpi) {
        DisplayMetrics.DENSITY_LOW -> density = "LDPI"
        DisplayMetrics.DENSITY_140 -> density = "LDPI - MDPI"
        DisplayMetrics.DENSITY_MEDIUM -> density = "MDPI"
        DisplayMetrics.DENSITY_180, DisplayMetrics.DENSITY_200, DisplayMetrics.DENSITY_220 -> density = "MDPI - HDPI"
        DisplayMetrics.DENSITY_HIGH -> density = "HDPI"
        DisplayMetrics.DENSITY_260, DisplayMetrics.DENSITY_280, DisplayMetrics.DENSITY_300 -> density = "HDPI - XHDPI"
        DisplayMetrics.DENSITY_XHIGH -> density = "XHDPI"
        DisplayMetrics.DENSITY_340, DisplayMetrics.DENSITY_360, DisplayMetrics.DENSITY_400, DisplayMetrics.DENSITY_420, DisplayMetrics.DENSITY_440 -> density =
            "XHDPI - XXHDPI"
        DisplayMetrics.DENSITY_XXHIGH -> density = "XXHDPI"
        DisplayMetrics.DENSITY_560, DisplayMetrics.DENSITY_600 -> density = "XXHDPI - XXXHDPI"
        DisplayMetrics.DENSITY_XXXHIGH -> density = "XXXHDPI"
        DisplayMetrics.DENSITY_TV -> density = "TVDPI"
        else -> density = "UNKNOWN"
    }

    return density
}
</code>```

Make sure to regularly check if new densities are added.

Body:
In Android you can get the screen density like this:

public static String getScreenDensity(Context context)
{
    String density;
    switch (context.getResources().getDisplayMetrics().densityDpi)
    {
        case DisplayMetrics.DENSITY_LOW:
            density = "LDPI";
            break;
        case DisplayMetrics.DENSITY_140:
            density = "LDPI - MDPI";
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            density = "MDPI";
            break;
        case DisplayMetrics.DENSITY_180:
        case DisplayMetrics.DENSITY_200:
        case DisplayMetrics.DENSITY_220:
            density = "MDPI - HDPI";
            break;
        case DisplayMetrics.DENSITY_HIGH:
            density = "HDPI";
            break;
        case DisplayMetrics.DENSITY_260:
        case DisplayMetrics.DENSITY_280:
        case DisplayMetrics.DENSITY_300:
            density = "HDPI - XHDPI";
            break;
        case DisplayMetrics.DENSITY_XHIGH:
            density = "XHDPI";
            break;
        case DisplayMetrics.DENSITY_340:
        case DisplayMetrics.DENSITY_360:
        case DisplayMetrics.DENSITY_400:
        case DisplayMetrics.DENSITY_420:
        case DisplayMetrics.DENSITY_440:
            density = "XHDPI - XXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXHIGH:
            density = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_560:
        case DisplayMetrics.DENSITY_600:
            density = "XXHDPI - XXXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXXHIGH:
            density = "XXXHDPI";
            break;
        case DisplayMetrics.DENSITY_TV:
            density = "TVDPI";
            break;
        default:
            density = "UNKNOWN";
            break;
    }

    return density;
}

And in Kotlin like this:

fun getScreenDensity(context: Context): String {
    val density: String
    when (context.resources.displayMetrics.densityDpi) {
        DisplayMetrics.DENSITY_LOW -> density = "LDPI"
        DisplayMetrics.DENSITY_140 -> density = "LDPI - MDPI"
        DisplayMetrics.DENSITY_MEDIUM -> density = "MDPI"
        DisplayMetrics.DENSITY_180, DisplayMetrics.DENSITY_200, DisplayMetrics.DENSITY_220 -> density = "MDPI - HDPI"
        DisplayMetrics.DENSITY_HIGH -> density = "HDPI"
        DisplayMetrics.DENSITY_260, DisplayMetrics.DENSITY_280, DisplayMetrics.DENSITY_300 -> density = "HDPI - XHDPI"
        DisplayMetrics.DENSITY_XHIGH -> density = "XHDPI"
        DisplayMetrics.DENSITY_340, DisplayMetrics.DENSITY_360, DisplayMetrics.DENSITY_400, DisplayMetrics.DENSITY_420, DisplayMetrics.DENSITY_440 -> density =
            "XHDPI - XXHDPI"
        DisplayMetrics.DENSITY_XXHIGH -> density = "XXHDPI"
        DisplayMetrics.DENSITY_560, DisplayMetrics.DENSITY_600 -> density = "XXHDPI - XXXHDPI"
        DisplayMetrics.DENSITY_XXXHIGH -> density = "XXXHDPI"
        DisplayMetrics.DENSITY_TV -> density = "TVDPI"
        else -> density = "UNKNOWN"
    }

    return density
}

Make sure to regularly check if new densities are added.