问:
Entity Framework .NET Core returns 'Data is Null. This method or property cannot be called on Null values.' but not in Debugger
The problem:

on C#, MVC API with Angular 6 front end on IIS deployed solution.

A simple HTML table with 8 filtering fields on specific columns runs queries on the back-end through an API HttpGet call. The function itself works ok, but NOT for specific strings. On the field 'Description' for example, the back-end returns 'Data is Null. This method or property cannot be called on Null values' when below strings are used. Values are correctly passed between front and back-end and the API call mostly returns the appropriate data.

However strings such as app and longer than app such as application, cert and longer such as certificate will return the 'Data is Null' error.

If I use f as the input for transmittal I get the 'Data is Null' error.
If however I use crc on document and THEN use f as the input for transmittal the function returns normal data??

This only happens in the deployed state, the problem does not occur when debugging the code. When debugging, the code returns the expected results and always produces the correct response.

the service call using a set of 'chained' where statements to build an IQueryable which gets called to return a .ToListAsync() at the end of the sequence.

Using:

IIS, version 10, running on Virtual Machine

Operating System IIS virtual machine: Windows Server 2016

.Net Core: 2.1

EntityFrameworkCore: 2.1.11

SQL Server 2012 (running on same VM)

VS 2019

SQL Server Management Studio 2018

the Controller code

```<code>[HttpGet("[action]")]
public async Task<IActionResult> Search(string TR, string DA, string DO, string RE, string TY, string DD, string DI, string OR, string DE)
        {
        return Ok(await _archiveService.Search(TR, DA, DO, RE, TY, DD, DI, OR, DE));
        }
</code>```

the ArchiveService code

```<code>public async Task<IEnumerable<object>> Search(
            string transmittal,
            string date,
            string document,
            string revision,
            string type,
            string description,
            string discipline,
            string origin,
            string destination)
        {
                var result = _db.TblCorrespondenceLog.AsQueryable();

                if (!string.IsNullOrEmpty(transmittal))
                    result = result.Where(f => f.TransmittalNo.Contains(transmittal));

                if (!string.IsNullOrEmpty(date))
                {

                }

                if (!string.IsNullOrEmpty(document))
                    result = result.Where(f => f.CompanyDocumentNo.ToLower().Contains(document));

                if (!string.IsNullOrEmpty(type))
                    result = result.Where(f => f.DocumentType.ToLower() == type);

                if (!string.IsNullOrEmpty(description))
                    result = result.Where(f => f.DocumentDescription.ToLower().Contains(description));

                if (!string.IsNullOrEmpty(discipline))
                    result = result.Where(f => f.Discipline.ToLower() == discipline);

                if (!string.IsNullOrEmpty(origin))
                    result = result.Where(f => f.OriginatorCode.ToLower() == origin);

                if (!string.IsNullOrEmpty(destination))
                    result = result.Where(f => f.SupplierCode.ToLower() == destination);

                return await result.ToListAsync();
}
</code>```

The fields that give the errors are the fields that have the .Contains() clause

When I use SQL writer to obtain the query that get's fired to the server I get the below query, which results in the 'Data is Null' error when the .ToListAsync() gets called:

```<code>SELECT [f].[uID], [f].[Action_Required], [f].[Approved_Responded], [f].[Area_Code], [f].[Company_Document_No],
[f].[Discipline], [f].[Document_Description], [f].[Document_Type], [f].[fileUID], [f].[Link], [f].[Originator_Code],
[f].[Reference_Document], [f].[ResponsibelEngineer], [f].[ResubDate], [f].[ResubTransmittal], [f].[Rev],
[f].[Sequential_Number], [f].[Sheet_Number], [f].[Supplier_Code], [f].[TDate], [f].[Transmittal_Date], [f].[Transmittal_No],
[f].[Transmittal_Type], [f].[TRN_Originator], [f].[TurnAroundDate], [f].[Unit_Code],
[f].[TransmitUID]
FROM [tblCorrespondenceLog] AS [f]
WHERE CHARINDEX(N'f', [f].[Transmittal_No]) > 0
</code>```

Which, when fired from SMSS (SQL Server Management Studio 2018) works perfectly fine?

If I use crc as input for document I get data returned as normal but the query is only marginally different:

```<code>SELECT [f].[uID], [f].[Action_Required], [f].[Approved_Responded], [f].[Area_Code], [f].[Company_Document_No],
[f].[Discipline], [f].[Document_Description], [f].[Document_Type], [f].[fileUID], [f].[Link], [f].[Originator_Code],
[f].[Reference_Document], [f].[ResponsibelEngineer], [f].[ResubDate], [f].[ResubTransmittal], [f].[Rev],
[f].[Sequential_Number], [f].[Sheet_Number], [f].[Supplier_Code], [f].[TDate], [f].[Transmittal_Date], [f].[Transmittal_No],
[f].[Transmittal_Type], [f].[TRN_Originator], [f].[TurnAroundDate], [f].[Unit_Code],
[f].[TransmitUID]
FROM [tblCorrespondenceLog] AS [f]
WHERE (CHARINDEX(N'f', [f].[Transmittal_No]) > 0) AND (CHARINDEX(N'crc', LOWER([f].[Company_Document_No])) > 0)
</code>```

So...
Why does entity framework give me a 'Data is Null' error only on specific strings and in specific combinations. Where the function would otherwise return proper values even if filtering on the 'problem' fields (using different strings of course)?

答:
It is caused by a disconnect between the .NET Core Entity Class and the database table;

The class Configiration was set as:

```<code>     builder.Property(e => e.DocumentDescription)
            .IsRequired()
            .HasColumnName("Document_Description")
            .HasMaxLength(150);
</code>```

but the database table had this field as allow null therefore sometimes returning null where entity framework did not expect to see a null.

removing the .IsRequired() bit did the job.

```<code>     builder.Property(e => e.DocumentDescription)
            //.IsRequired()
            .HasColumnName("Document_Description")
            .HasMaxLength(150);
</code>```

Funny enough though, this didn't produce errors in the development environment but DID cause problems when deployed. I haven't been able to figure out why there is a difference, but at least it works now!

Body:
The problem:

on C#, MVC API with Angular 6 front end on IIS deployed solution.

A simple HTML table with 8 filtering fields on specific columns runs queries on the back-end through an API HttpGet call. The function itself works ok, but NOT for specific strings. On the field 'Description' for example, the back-end returns 'Data is Null. This method or property cannot be called on Null values' when below strings are used. Values are correctly passed between front and back-end and the API call mostly returns the appropriate data.

However strings such as app and longer than app such as application, cert and longer such as certificate will return the 'Data is Null' error.

If I use f as the input for transmittal I get the 'Data is Null' error.
If however I use crc on document and THEN use f as the input for transmittal the function returns normal data??

This only happens in the deployed state, the problem does not occur when debugging the code. When debugging, the code returns the expected results and always produces the correct response.

the service call using a set of 'chained' where statements to build an IQueryable which gets called to return a .ToListAsync() at the end of the sequence.

Using:

IIS, version 10, running on Virtual Machine

Operating System IIS virtual machine: Windows Server 2016

.Net Core: 2.1

EntityFrameworkCore: 2.1.11

SQL Server 2012 (running on same VM)

VS 2019

SQL Server Management Studio 2018

the Controller code

[HttpGet("[action]")]
public async Task<IActionResult> Search(string TR, string DA, string DO, string RE, string TY, string DD, string DI, string OR, string DE)
        {
        return Ok(await _archiveService.Search(TR, DA, DO, RE, TY, DD, DI, OR, DE));
        }

the ArchiveService code

public async Task<IEnumerable<object>> Search(
            string transmittal,
            string date,
            string document,
            string revision,
            string type,
            string description,
            string discipline,
            string origin,
            string destination)
        {
                var result = _db.TblCorrespondenceLog.AsQueryable();

                if (!string.IsNullOrEmpty(transmittal))
                    result = result.Where(f => f.TransmittalNo.Contains(transmittal));

                if (!string.IsNullOrEmpty(date))
                {

                }

                if (!string.IsNullOrEmpty(document))
                    result = result.Where(f => f.CompanyDocumentNo.ToLower().Contains(document));

                if (!string.IsNullOrEmpty(type))
                    result = result.Where(f => f.DocumentType.ToLower() == type);

                if (!string.IsNullOrEmpty(description))
                    result = result.Where(f => f.DocumentDescription.ToLower().Contains(description));

                if (!string.IsNullOrEmpty(discipline))
                    result = result.Where(f => f.Discipline.ToLower() == discipline);

                if (!string.IsNullOrEmpty(origin))
                    result = result.Where(f => f.OriginatorCode.ToLower() == origin);

                if (!string.IsNullOrEmpty(destination))
                    result = result.Where(f => f.SupplierCode.ToLower() == destination);

                return await result.ToListAsync();
}

The fields that give the errors are the fields that have the .Contains() clause

When I use SQL writer to obtain the query that get's fired to the server I get the below query, which results in the 'Data is Null' error when the .ToListAsync() gets called:

SELECT [f].[uID], [f].[Action_Required], [f].[Approved_Responded], [f].[Area_Code], [f].[Company_Document_No],
[f].[Discipline], [f].[Document_Description], [f].[Document_Type], [f].[fileUID], [f].[Link], [f].[Originator_Code],
[f].[Reference_Document], [f].[ResponsibelEngineer], [f].[ResubDate], [f].[ResubTransmittal], [f].[Rev],
[f].[Sequential_Number], [f].[Sheet_Number], [f].[Supplier_Code], [f].[TDate], [f].[Transmittal_Date], [f].[Transmittal_No],
[f].[Transmittal_Type], [f].[TRN_Originator], [f].[TurnAroundDate], [f].[Unit_Code],
[f].[TransmitUID]
FROM [tblCorrespondenceLog] AS [f]
WHERE CHARINDEX(N'f', [f].[Transmittal_No]) > 0

Which, when fired from SMSS (SQL Server Management Studio 2018) works perfectly fine?

If I use crc as input for document I get data returned as normal but the query is only marginally different:

SELECT [f].[uID], [f].[Action_Required], [f].[Approved_Responded], [f].[Area_Code], [f].[Company_Document_No],
[f].[Discipline], [f].[Document_Description], [f].[Document_Type], [f].[fileUID], [f].[Link], [f].[Originator_Code],
[f].[Reference_Document], [f].[ResponsibelEngineer], [f].[ResubDate], [f].[ResubTransmittal], [f].[Rev],
[f].[Sequential_Number], [f].[Sheet_Number], [f].[Supplier_Code], [f].[TDate], [f].[Transmittal_Date], [f].[Transmittal_No],
[f].[Transmittal_Type], [f].[TRN_Originator], [f].[TurnAroundDate], [f].[Unit_Code],
[f].[TransmitUID]
FROM [tblCorrespondenceLog] AS [f]
WHERE (CHARINDEX(N'f', [f].[Transmittal_No]) > 0) AND (CHARINDEX(N'crc', LOWER([f].[Company_Document_No])) > 0)

So...
Why does entity framework give me a 'Data is Null' error only on specific strings and in specific combinations. Where the function would otherwise return proper values even if filtering on the 'problem' fields (using different strings of course)?

Body:
It is caused by a disconnect between the .NET Core Entity Class and the database table;

The class Configiration was set as:

     builder.Property(e => e.DocumentDescription)
            .IsRequired()
            .HasColumnName("Document_Description")
            .HasMaxLength(150);

but the database table had this field as allow null therefore sometimes returning null where entity framework did not expect to see a null.

removing the .IsRequired() bit did the job.

     builder.Property(e => e.DocumentDescription)
            //.IsRequired()
            .HasColumnName("Document_Description")
            .HasMaxLength(150);

Funny enough though, this didn't produce errors in the development environment but DID cause problems when deployed. I haven't been able to figure out why there is a difference, but at least it works now!


来源: stackexchange

问:
Big Oh! algorithms running in O(4^N)
For algorithms running in

```<code>O(16^N)
</code>```

If we triple the size, the time is multiplied by what number??

答:
This is an interesting question because while equivalent questions for runtimes like Θ(n) or Θ(n3) have clean answers, the answer here is a bit more nuanced.

Let's start with a simpler question. We have an algorithm whose runtime is Θ(n2), and on a "sufficiently large" input the runtime is T seconds. What should we expect the runtime to be once we triple the size of the input? To answer this, let's imagine, just for simplicity's sake, that the actual runtime of this function is closely approximated by cn2, and let's have k be the "sufficiently large" input we plugged into it. Then, plugging in 3k, we see that the runtime is

c(3k)2 = 9ck2 = 9(ck2) = 9T.

That last step follows because the cost of running the algorithm on an input of size k is T, meaning that ck2 = T.

Something important to notice here - tripling the size of the input does not change the fact that the runtime here is Θ(n2). The runtime is still quadratic; we're just changing how big the input is.

More generally, for any algorithm whose runtime is Θ(nm) for some fixed constant m, the runtime will grow by roughly a factor of 3m if you triple the size of the input. That's because

c(3k)m = 3mckm = 3mT.

But something interesting happens if we try performing this same analysis on a function whose runtime is Θ(4n). Let's imagine that we ran this algorithm on some input k and it took T time units to finish. Then running this algorithm on an input of size 3k will take time roughly

c43k = c4k42k = T42k = 16kT.

Notice how we aren't left with a constant multiple of the original cost, but rather something that's 16k times bigger. In particular, that means that the amount by which the algorithm slows down will depend on how big the input is. For example, the slowdown going from input size 10 to input size 30 is a factor of 1620, while the slowdown going from input size 30 to input size 90 is a staggering 1660. For what it's worth, 1660 = 2240, which is pretty close to the number of atoms in the observable universe.

And, intuitively, that makes sense. Exponential functions grow at a rate proportional to how big they already are. That means that the scale in runtime for doubling or tripling the size of the input will lead to a runtime change that depends on the size of that input.

And, as above, notice that the runtime is not now Θ(43n). The runtime is still Θ(4n); we're just changing which inputs we're plugging in.

So, to summarize:

The runtime of the function slows down by a factor of 42n if you triple the size of the input n. This means that the slowdown depends on how big the input is.

The runtime of the function stays at Θ(4n) when we do this. All that's changing is where we're evaluating the 4n.

Hope this helps!

ContentLicense: CC BY-SA 4.0

Title: Big Oh! algorithms running in O(4^N)

Body:
For algorithms running in

O(16^N)

If we triple the size, the time is multiplied by what number??


问:
Import ES6 module from http url in Typescript
I am writing an ES6 module which depends on the other ES6 module specified with http url like this:

```<code>import { el, mount } from "https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js";
const pElem = el("p") // definitely works in Javascript
</code>```

When I tried to translate my module in Typescript, I got this error:

Cannot find module 'https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js' or its corresponding type declarations.

I'm using ts-watch npm module to compile Typescript, and it works fine unless I don't use the import from https://....

I also know that if I tried to import npm module (e.g. import {el} from "redom") it works as well. But what I am writing is a module for web browser, not that of npm. With this reason, using webpack is not an option.

答:
Thanks to @acrazing's comment, I managed to resolve this problem. Here's how:

In a new ts file:

```<code>declare module 'https://*'
</code>```

This mutes the error that Typescript compiler attempts to read type declaration.

If you want to access type declaration as a node dependency, paste this in a new ts file:

```<code>declare module 'https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js' {
    export * from 'redom'
}
</code>```

and add redom dependency in package.json

```<code>  "dependencies": {
    "redom": "3.26.0",
    ...
  },
</code>```

Then, type declaration is read from local ./node_modules directory, VSCode recognizes the types as well.

Body:
I am writing an ES6 module which depends on the other ES6 module specified with http url like this:

import { el, mount } from "https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js";
const pElem = el("p") // definitely works in Javascript

When I tried to translate my module in Typescript, I got this error:

Cannot find module 'https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js' or its corresponding type declarations.

I'm using ts-watch npm module to compile Typescript, and it works fine unless I don't use the import from https://....

I also know that if I tried to import npm module (e.g. import {el} from "redom") it works as well. But what I am writing is a module for web browser, not that of npm. With this reason, using webpack is not an option.

Body:
Thanks to @acrazing's comment, I managed to resolve this problem. Here's how:

In a new ts file:

declare module 'https://*'

This mutes the error that Typescript compiler attempts to read type declaration.

If you want to access type declaration as a node dependency, paste this in a new ts file:

declare module 'https://cdnjs.cloudflare.com/ajax/libs/redom/3.26.0/redom.es.js' {
    export * from 'redom'
}

and add redom dependency in package.json

  "dependencies": {
    "redom": "3.26.0",
    ...
  },

Then, type declaration is read from local ./node_modules directory, VSCode recognizes the types as well.


问:
RJS with Devise gem
What would be the proper way to set Devise gem (ruby on rails v3) in RJS style (example: http://railscasts.com/episodes/43-ajax-with-rjs)?

I usually create a create.js.erb file with alert(@error). When using devise I don't know how to properly get @error value. I would like to display all messages as javascript alerts.

答:
I think, to achieve this you will need to write your own controllers (inherited from devise) and views. And then add respond_to :html, :js to this controllers. After this, controllers will be able to respond to javascript requests and you can manage your alerts.
Read doc for how to create custom Devise views here: Devise

ContentLicense: CC BY-SA 3.0

Title: RJS with Devise gem


问:
How can I convert a column with datetime format to just a year?
I have a column of datetime with values like 10/10/49 20:30, but need to mutate the dataframe to have a column of just the date in format 1949. The code below is just bringing me a column of NA. How can I extract the year? I need to use dplyr to solve this!</p>
```<code>df %>%
  mutate(., year = format(as.Date(x = datetime, format="%d/%m/%y %I:%M:%S %p"),"%Y"))
</code>```

答:
We can use base R to do this

```<code>df$datetime <- as.POSIXct(df$datetime, format = "%d/%m/%y %I:%M:%S %p")
df$year <- as.integer(format(df$datetime, "%Y"))
df$rev_year <- with(df, ifelse(year > 2020, year - 100, year))
</code>```

Body:
I have a column of datetime with values like 10/10/49 20:30, but need to mutate the dataframe to have a column of just the date in format 1949. The code below is just bringing me a column of NA. How can I extract the year? I need to use dplyr to solve this!

df %>%
  mutate(., year = format(as.Date(x = datetime, format="%d/%m/%y %I:%M:%S %p"),"%Y"))

Body:
We can use base R to do this

df$datetime <- as.POSIXct(df$datetime, format = "%d/%m/%y %I:%M:%S %p")
df$year <- as.integer(format(df$datetime, "%Y"))
df$rev_year <- with(df, ifelse(year > 2020, year - 100, year))


问:
What is an Integer?
An integer programming problem is a mathematical optimization or feasibility program in which some or all of the variables are restricted to be integers.</p>

答:
Your myIntStrDict variable is declared as BDictionary<int, std::string>. BDictionary's Key is int and E is std::string.

When you call myIntStrDict.removeAny(strData), the BDictionary::removeAny() method takes an E& aka std::string& as input, and strData is a std::string, so all is OK.

Inside of BDictionary, its dictionary member is declared as ABag<KVpair<Key, E>>*. ABag's E is KVpair<Key, E>.

The ABag::removeTop() method takes an E& aka KVpair<Key, E>& as input, not a std::string& like you are expecting.

So, when you are calling dictionary->removeTop(returnValue), you are passing a std::string where a KVpair is expected, and that is why the compiler fails.

To do what you are attempting, you need to fix the implementation of your BDictionary::removeAny() method to accept a KVpair, and the nyou can extract the std::string for that, eg:

```<code>//BDictionary.h
template <typename Key, typename E>
class BDictionary : public Dictionary<Key, E> {

    ABag<KVpair<Key, E>>* dictionary;   //Dictionary object

    bool removeAny(E& returnValue) {     //The Dictionary method that accepts an E& value
        KVpair<Key, E> pair;
        bool res = dictionary->removeTop(pair);
        if (res) returnValue = pair.second; // or however KVpair refers to its 2nd element
        return res;
    }
};
</code>```

Title: What is an Integer?

Body:
Your myIntStrDict variable is declared as BDictionary<int, std::string>. BDictionary's Key is int and E is std::string.

When you call myIntStrDict.removeAny(strData), the BDictionary::removeAny() method takes an E& aka std::string& as input, and strData is a std::string, so all is OK.

Inside of BDictionary, its dictionary member is declared as ABag<KVpair<Key, E>>*. ABag's E is KVpair<Key, E>.

The ABag::removeTop() method takes an E& aka KVpair<Key, E>& as input, not a std::string& like you are expecting.

So, when you are calling dictionary->removeTop(returnValue), you are passing a std::string where a KVpair is expected, and that is why the compiler fails.

To do what you are attempting, you need to fix the implementation of your BDictionary::removeAny() method to accept a KVpair, and the nyou can extract the std::string for that, eg:

//BDictionary.h
template <typename Key, typename E>
class BDictionary : public Dictionary<Key, E> {

    ABag<KVpair<Key, E>>* dictionary;   //Dictionary object

    bool removeAny(E& returnValue) {     //The Dictionary method that accepts an E& value
        KVpair<Key, E> pair;
        bool res = dictionary->removeTop(pair);
        if (res) returnValue = pair.second; // or however KVpair refers to its 2nd element
        return res;
    }
};


问:
How to download maven dependency as *.jar file?
I attempt to implement the example from here, but upon the Maven dependencies installation I can't find jar file amongst downloaded dependencies.

My pom.xml looks like this:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- This is often your domain name (reversed.)  -->
    <groupId>com.abc</groupId>
    <!-- The name of this project (actually, the name of the artifact, which is the thing that this project produces. A jar in this case.) -->
    <artifactId>javaparser-maven-sample</artifactId>
    <!-- The version of this project. SNAPSHOT means "we're still working on it" -->
    <version>1.0-SNAPSHOT</version>

    <properties>
        <!-- Tell Maven we want to use Java 8 -->
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <!-- Tell Maven to treat all source files as UTF-8 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>2.5.7</geotools.version>
    </properties>
   <repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net repository</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>osgeo</id>
        <name>Open Source Geospatial Foundation Repository</name>
        <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
    <repository> <!--Add the snapshot repository here-->
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>opengeo</id>
        <name>OpenGeo Maven Repository</name>
        <url>http://repo.opengeo.org</url>
    </repository>
</repositories>

    <dependencies>
        <!-- Here are all your dependencies. Currently only one. These are automatically downloaded from https://mvnrepository.com/ -->
        <dependency>
            <groupId>com.github.javaparser</groupId>
            <artifactId>javaparser-core</artifactId>
            <version>3.15.21</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/mil.nga.geopackage/geopackage -->
        <dependency>
            <groupId>mil.nga.geopackage</groupId>
            <artifactId>geopackage</artifactId>
            <version>3.5.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.geotools/gt-api -->
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-api</artifactId>
            <version>20.5</version>
        </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.geotools/gt-geometry -->
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-geometry</artifactId>
        <version>2.5-M2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.geotools/gt-referencing -->
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-referencing</artifactId>
        <version>17.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.locationtech.jts.io/jts-io-common -->
    <dependency>
        <groupId>org.locationtech.jts.io</groupId>
        <artifactId>jts-io-common</artifactId>
        <version>1.16.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.opengis/geoapi -->
    <dependency>
        <groupId>org.opengis</groupId>
        <artifactId>geoapi</artifactId>
        <version>3.0.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.geotools/gt-jts-wrapper -->
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jts-wrapper</artifactId>
    <version>17.0</version>
    <scope>test</scope>
</dependency>
    <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>17.0</version>
        </dependency>

    </dependencies>

    <!-- This blob of configuration tells Maven to make the jar executable. You can run it with:
    mvn clean package
    java -jar target/javaparser-maven-sample-1.0-SNAPSHOT-shaded.jar
    -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.abc.conversion.LogicPositivizer</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

I am able to download all the jars except geotools related jars. When I clean and run the project, in the .m2 folder I am not able to see the geotool related jars. Even in the maven repository I am not able to download the jar file.

Maven repo

Is there any alternative way to proceed?

答:
The repository run by Boundless has been replaced by one hosted by OSGeo.  The OSGeo webdav repo was merged into the new OSGeo repo.  Details are here (https://docs.geotools.org/latest/userguide/tutorial/quickstart/maven.html)

Replace this block

```<code><repository>
    <id>osgeo</id>
    <name>Open Source Geospatial Foundation Repository</name>
    <url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository> <!--Add the snapshot repository here-->
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <id>opengeo</id>
    <name>OpenGeo Maven Repository</name>
    <url>http://repo.opengeo.org</url>
</repository>
</code>```

with

```<code>  <repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repository>
  <repository>
    <id>osgeo-snapshot</id>
    <name>OSGeo Snapshot Repository</name>
    <url>https://repo.osgeo.org/repository/snapshot/</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>false</enabled></releases>
  </repository>
</code>```

Body:
I attempt to implement the example from here, but upon the Maven dependencies installation I can't find jar file amongst downloaded dependencies.

My pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.abc</groupId>

    <artifactId>javaparser-maven-sample</artifactId>

    <version>1.0-SNAPSHOT</version>

    <properties>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>2.5.7</geotools.version>
    </properties>
   <repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net repository</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>osgeo</id>
        <name>Open Source Geospatial Foundation Repository</name>
        <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
    <repository>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>opengeo</id>
        <name>OpenGeo Maven Repository</name>
        <url>http://repo.opengeo.org</url>
    </repository>
</repositories>

    <dependencies>

        <dependency>
            <groupId>com.github.javaparser</groupId>
            <artifactId>javaparser-core</artifactId>
            <version>3.15.21</version>
        </dependency>

        <dependency>
            <groupId>mil.nga.geopackage</groupId>
            <artifactId>geopackage</artifactId>
            <version>3.5.0</version>
        </dependency>

        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-api</artifactId>
            <version>20.5</version>
        </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>${geotools.version}</version>
    </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-geometry</artifactId>
        <version>2.5-M2</version>
    </dependency>

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-referencing</artifactId>
        <version>17.1</version>
    </dependency>

    <dependency>
        <groupId>org.locationtech.jts.io</groupId>
        <artifactId>jts-io-common</artifactId>
        <version>1.16.1</version>
    </dependency>

    <dependency>
        <groupId>org.opengis</groupId>
        <artifactId>geoapi</artifactId>
        <version>3.0.0</version>
    </dependency>

<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jts-wrapper</artifactId>
    <version>17.0</version>
    <scope>test</scope>
</dependency>
    <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>17.0</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.abc.conversion.LogicPositivizer</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I am able to download all the jars except geotools related jars. When I clean and run the project, in the .m2 folder I am not able to see the geotool related jars. Even in the maven repository I am not able to download the jar file.

Maven repo

Is there any alternative way to proceed?

Body:
The repository run by Boundless has been replaced by one hosted by OSGeo.  The OSGeo webdav repo was merged into the new OSGeo repo.  Details are here (https://docs.geotools.org/latest/userguide/tutorial/quickstart/maven.html)

Replace this block

<repository>
    <id>osgeo</id>
    <name>Open Source Geospatial Foundation Repository</name>
    <url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository> <!--Add the snapshot repository here-->
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <id>opengeo</id>
    <name>OpenGeo Maven Repository</name>
    <url>http://repo.opengeo.org</url>
</repository>

with

  <repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repository>
  <repository>
    <id>osgeo-snapshot</id>
    <name>OSGeo Snapshot Repository</name>
    <url>https://repo.osgeo.org/repository/snapshot/</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>false</enabled></releases>
  </repository>


问:
Cannot implicitly convert type 'float' to 'UnityEngine.Vector3' When Using AddExplosionForce
Whenever I press the spacebar, I want an explosive force with an z-axis offset to act on my player. However, it gives me the error: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'</p>

```<code>if (Input.GetKeyDown("space"))
        {
            Vector3 rocketLoc = new Vector3(transform.position.x, transform.position.y, transform.position.z);
            rocketLoc.x = rocketLoc.x + 20.00f;
            rb.AddExplosionForce(20.00f, rocketLoc, 20.00f, 20.00f, ForceMode.Impulse);
            StartCoroutine(WaitAfterBlast());
        }
</code>```

答:
The error is very self-explainatory; it's is because you cannot convert float to a Vector3. There's no way for the program to assign a 20f when it expects a Vector3(x, y, z).

There is nothing that will cause an that exception in the code you supplied. If the exception points to this code, it's probably because it isn't the built code, or something like that.

Body:
Whenever I press the spacebar, I want an explosive force with an z-axis offset to act on my player. However, it gives me the error: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'

if (Input.GetKeyDown("space"))
        {
            Vector3 rocketLoc = new Vector3(transform.position.x, transform.position.y, transform.position.z);
            rocketLoc.x = rocketLoc.x + 20.00f;
            rb.AddExplosionForce(20.00f, rocketLoc, 20.00f, 20.00f, ForceMode.Impulse);
            StartCoroutine(WaitAfterBlast());
        }


问:
Understanding python nested iteration inside a list comprehension
I am having a hard time interpreting nested iteration inside a list comprehension. Below code

```<code>movie = []
genre = []
for movie_ids in ratings["movie_id"].values:
  movie.append(movie_ids)
  genre.append([x for movie_id in movie_ids for x in genres_dict[movie_id]])
</code>```

If I print genre[0] suppose I see a result [a,b,c]

My understanding from this and many others on the internet was that I can replace the line

```<code>genre.append([x for movie_id in movie_ids for x in genres_dict[movie_id]])
</code>```

With

```<code>for movie_id in movie_ids:
    if movie_id in genres_dict:
      genre.append(genres_dict[movie_id])
</code>```

But that gives a different result when I print genre[0]

What am I missing?

Please suggest

答:
The list comprehension is actually flattening the array for you as it iterates over the inner content also.

The equivalent code block would be this. Notice the extend vs append.

```<code>for movie_id in movie_ids:
    if movie_id in genres_dict:
      genre.extend(genres_dict[movie_id])
</code>```

The extend takes care of iterating over each item and adding it to the genre list. See docs for append vs extend.
https://docs.python.org/3/tutorial/datastructures.html

Body:
I am having a hard time interpreting nested iteration inside a list comprehension. Below code

movie = []
genre = []
for movie_ids in ratings["movie_id"].values:
  movie.append(movie_ids)
  genre.append([x for movie_id in movie_ids for x in genres_dict[movie_id]])

If I print genre[0] suppose I see a result [a,b,c]

My understanding from this and many others on the internet was that I can replace the line

genre.append([x for movie_id in movie_ids for x in genres_dict[movie_id]])

With

for movie_id in movie_ids:
    if movie_id in genres_dict:
      genre.append(genres_dict[movie_id])

But that gives a different result when I print genre[0]

What am I missing?

Please suggest

Body:
The list comprehension is actually flattening the array for you as it iterates over the inner content also.

The equivalent code block would be this. Notice the extend vs append.

for movie_id in movie_ids:
    if movie_id in genres_dict:
      genre.extend(genres_dict[movie_id])

The extend takes care of iterating over each item and adding it to the genre list. See docs for append vs extend.
https://docs.python.org/3/tutorial/datastructures.html


问:
In nextjs, does the code for "/api" routes end up in the browser at any point? If so Is there a way to force server-side-only execution?
I'm just now realizing this behavior about nextjs env vars here, which is different from how nodejs apps are usually set up:

Note: .env files should be included in your repository, and
  .env*.local should be in .gitignore, as those files are intended to be
  ignored. Consider .local files as a good place for secrets, and
  non-local files as a good place for defaults.

So I'm thinking of restricting myself to using a secret available only at build-time, to be used inside a "backend" /api route.

But do /api routes even behave like true backends? Since nextjs is SSR only when it has to be (?), I presume this /api code can also end up in the browser, therefore exposing the secret? Is there a way to force code to only run server-side and not in-browser? I am new to SSR concepts. My "real" backend won't be up for a while. This is not a hugely important secret, but still. Thx.

答:
API routes won't end up in the client bundle, so any code you put in /pages/api will stay hidden from the user. These routes are meant to be run exclusively on a server environment.

The same concept applies to getStaticProps which only runs on a server during build.

NextJS has a mechanism called "inlined environment variables". Any references to environment variables that start with NEXT_PUBLIC_ will be automatically replaced with their values. So if your local/build/production machine has the variable NEXT_PUBLIC_APPNAME set, NextJS will replace references to process.env.NEXT_PUBLIC_APPNAME with the variable's value.

Alternatively you can define variables in an .env file. These will also be used by your application, and may end up in your client bundle if you reference them in any code that renders on the client (like the JSX in pages/about.js).

Conclusion: secrets should be added to .env, and only be referenced in server-side code like API routes and getStaticProps.

You may also be interested in this tool: https://next-code-elimination.vercel.app/

It lets you verify that your server-side code stays out of the client bundle.


问:
C++ copy construct rvalue reference question
I'm learning the rvalue reference concept in c++.

When testing the following code, I found the "fun" was called despite it not using fun(abc &&) to accept the temporary object(prvalue).

```<code>
class abc
{
};
void fun(abc &)
{
    cout << 1111111 << endl;
}
void main()
{
    fun(abc());
}

</code>```

output: 1111111

If this is allowed due to temporary materialisation

Why does the following code fail to compile?

```<code>void fun(int &)
{
    cout << 1111111 << endl;
}
void main()
{
    fun(5);
}

</code>```

Output: Compiler error!

many thanks

答:
The reason why both fail to compile is that temporaries cannot be bound to non-const references.

In the first case, the expression abc() constructs a temporary abc object.  Trying to pass it to fun() tries to bind the temporary to a non-const reference; this is disallowed.

The second case is effectively the same thing: the compiler tries to use 5 to construct an int temporary, but then fails to bind it to the non-const reference.

```<code>int const & a = 5; // allowed
int & b = 5;       // disallowed
</code>```

This was an intentional design decision, intended to prevent what would otherwise be very easy mistakes to make.  Let's pretend this rule doesn't exist:

```<code>void add_one(double & i) {
    i += 1;
}

void something() {
    int x = 5;
    add_one(x);
    std::cout << x;
}
</code>```

Wait... why is x 5 instead of 6!?  Because x was used to construct a double temporary, which bound to the reference argument.  add_one() added 1 to the temporary.  Then the temporary is destroyed when control returns to something() and the value of x was never changed.

But, since temporaries cannot bind to non-const references, the add_one(x) line will instead fail to compile.  This saves the programmer from having to figure out that an invisible temporary was implicitly created and destroyed on that one line of code.

Body:
I'm learning the rvalue reference concept in c++.

When testing the following code, I found the "fun" was called despite it not using fun(abc &&) to accept the temporary object(prvalue).

class abc
{
};
void fun(abc &)
{
    cout << 1111111 << endl;
}
void main()
{
    fun(abc());
}

output: 1111111

If this is allowed due to temporary materialisation

Why does the following code fail to compile?

void fun(int &)
{
    cout << 1111111 << endl;
}
void main()
{
    fun(5);
}

Output: Compiler error!

many thanks

Body:
The reason why both fail to compile is that temporaries cannot be bound to non-const references.

In the first case, the expression abc() constructs a temporary abc object.  Trying to pass it to fun() tries to bind the temporary to a non-const reference; this is disallowed.

The second case is effectively the same thing: the compiler tries to use 5 to construct an int temporary, but then fails to bind it to the non-const reference.

int const & a = 5; // allowed
int & b = 5;       // disallowed

This was an intentional design decision, intended to prevent what would otherwise be very easy mistakes to make.  Let's pretend this rule doesn't exist:

void add_one(double & i) {
    i += 1;
}

void something() {
    int x = 5;
    add_one(x);
    std::cout << x;
}

Wait... why is x 5 instead of 6!?  Because x was used to construct a double temporary, which bound to the reference argument.  add_one() added 1 to the temporary.  Then the temporary is destroyed when control returns to something() and the value of x was never changed.

But, since temporaries cannot bind to non-const references, the add_one(x) line will instead fail to compile.  This saves the programmer from having to figure out that an invisible temporary was implicitly created and destroyed on that one line of code.


问:
Spring Boot - put data to update form using @PathVariable
When I try put data to update form using @PathVariable like this:
 Edit

Method in Controller:

```<code>@GetMapping("/turysci/updateForm/{idTurysta}")
public String updateformTurysta(@PathVariable Integer idTurysta,
                                Model model,
                                Authentication authentication)
{

    model.addAttribute("LoggedUser", authentication);

    Turysta turysta = turystaServiceImpl.getOneById(idTurysta);
    Uzytkownik uzytkownik = turysta.getUzytkownik();
    model.addAttribute("turysta", turysta);
    model.addAttribute("uzytkownik", uzytkownik);

    return "turysta/updateForm";
}
</code>```

I have problem in console like below but everything on site work fine...

```<code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: class org.springframework.web.context.request.ServletRequestAttributes cannot be cast to class org.springframework.web.context.request.WebRequest (org.springframework.web.context.request.ServletRequestAttributes and org.springframework.web.context.request.WebRequest are in unnamed module of loader 'app')
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:84) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:216) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:394) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:253) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
Caused by: java.lang.ClassCastException: class org.springframework.web.context.request.ServletRequestAttributes cannot be cast to class org.springframework.web.context.request.WebRequest (org.springframework.web.context.request.ServletRequestAttributes and org.springframework.web.context.request.WebRequest are in unnamed module of loader 'app')
    at grupa4.projektzespolowy.GOTTPKProjekt.controller.AppErrorController.getErrorAttributes(AppErrorController.java:84) ~[classes/:na]
    at grupa4.projektzespolowy.GOTTPKProjekt.controller.AppErrorController.error(AppErrorController.java:57) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    ... 59 common frames omitted
</code>```

If I'm using @RequestParam method, there is no problem.

```<code><td><a class="nav-link" href="/turysci/updateForm?id={{ turysta.getIdTurysta }}">Edytuj</a></td>
</code>```

Controller:

```<code>    @GetMapping("/turysci/updateForm")
    public String updateformTurysta(@RequestParam(value="id") Integer idTurysta,
                                    Model model,
                                    Authentication authentication)
    {

        model.addAttribute("LoggedUser", authentication);

        Turysta turysta = turystaServiceImpl.getOneById(idTurysta);
        Uzytkownik uzytkownik = turysta.getUzytkownik();
        model.addAttribute("turysta", turysta);
        model.addAttribute("uzytkownik", uzytkownik);

        return "turysta/updateForm";
    }
</code>```

Is there any way to make @PathVariable method runnable? I don't want URLs with ? and variable name.

答: This is old question but the problem was in links to css and js files in base html template. I had path like ../css/myCss.css instead of /css/myCss.css.

Body:
When I try put data to update form using @PathVariable like this:
 Edit

Method in Controller:

@GetMapping("/turysci/updateForm/{idTurysta}")
public String updateformTurysta(@PathVariable Integer idTurysta,
                                Model model,
                                Authentication authentication)
{

    model.addAttribute("LoggedUser", authentication);

    Turysta turysta = turystaServiceImpl.getOneById(idTurysta);
    Uzytkownik uzytkownik = turysta.getUzytkownik();
    model.addAttribute("turysta", turysta);
    model.addAttribute("uzytkownik", uzytkownik);

    return "turysta/updateForm";
}

I have problem in console like below but everything on site work fine...

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: class org.springframework.web.context.request.ServletRequestAttributes cannot be cast to class org.springframework.web.context.request.WebRequest (org.springframework.web.context.request.ServletRequestAttributes and org.springframework.web.context.request.WebRequest are in unnamed module of loader 'app')
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:84) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:216) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:394) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:253) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
    at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
Caused by: java.lang.ClassCastException: class org.springframework.web.context.request.ServletRequestAttributes cannot be cast to class org.springframework.web.context.request.WebRequest (org.springframework.web.context.request.ServletRequestAttributes and org.springframework.web.context.request.WebRequest are in unnamed module of loader 'app')
    at grupa4.projektzespolowy.GOTTPKProjekt.controller.AppErrorController.getErrorAttributes(AppErrorController.java:84) ~[classes/:na]
    at grupa4.projektzespolowy.GOTTPKProjekt.controller.AppErrorController.error(AppErrorController.java:57) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    ... 59 common frames omitted

If I'm using @RequestParam method, there is no problem.

Edytuj

Controller:

    @GetMapping("/turysci/updateForm")
    public String updateformTurysta(@RequestParam(value="id") Integer idTurysta,
                                    Model model,
                                    Authentication authentication)
    {

        model.addAttribute("LoggedUser", authentication);

        Turysta turysta = turystaServiceImpl.getOneById(idTurysta);
        Uzytkownik uzytkownik = turysta.getUzytkownik();
        model.addAttribute("turysta", turysta);
        model.addAttribute("uzytkownik", uzytkownik);

        return "turysta/updateForm";
    }

Is there any way to make @PathVariable method runnable? I don't want URLs with ? and variable name.


问:
Printing Right Triangles w/ Nested For-Loop
Here's my loop:

int height = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Printing a " + height + " by " + height + " right triangle...");

for (int i = 1; i <= height; i++)
{
    Console.WriteLine("*");
    for (int j = 1; j <= i; j++)
    {
        Console.Write("*");
    }
```

<p>And here is the resulting print (program takes a user input for the height, this example has a height of 5:</p>

<pre class="lang-none prettyprint-override"><code>*
**
***
****
****
</code>```

As you can see, I can't get the last star to print on the last row. This makes absolutely no sense to me, as I've compared it to many other similar constructs and there appears to be no discrepancies between the one I've constructed and the ones others have made. I just started coding about a month ago so I'm still a greenhorn.

答:
What looping operation would be complete without at least one LINQ solution? Ok, here you go:

```<code>    private static void TestRightAngle(int height)
    {
        var l = new int[height];
        int i = 0;
        l.ToList().ForEach(f => Console.WriteLine(string.Empty.PadRight(++i, '*')));
    }
</code>```

Yes, it's gratuitous and it's inefficient, but it does have that "Je Ne Sais Quoi"...it has that LINQ-appeal.

Body:
Here's my loop:

int height = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Printing a " + height + " by " + height + " right triangle...");

for (int i = 1; i <= height; i++)
{
    Console.WriteLine("*");
    for (int j = 1; j <= i; j++)
    {
        Console.Write("*");
    }

And here is the resulting print (program takes a user input for the height, this example has a height of 5:

*
**
***
****
****

As you can see, I can't get the last star to print on the last row. This makes absolutely no sense to me, as I've compared it to many other similar constructs and there appears to be no discrepancies between the one I've constructed and the ones others have made. I just started coding about a month ago so I'm still a greenhorn.

Body:
What looping operation would be complete without at least one LINQ solution? Ok, here you go:

    private static void TestRightAngle(int height)
    {
        var l = new int[height];
        int i = 0;
        l.ToList().ForEach(f => Console.WriteLine(string.Empty.PadRight(++i, '*')));
    }

Yes, it's gratuitous and it's inefficient, but it does have that "Je Ne Sais Quoi"...it has that LINQ-appeal.


问:
How do I initialize variables at startup in a Blazor webassembly app?
In UWP, I would programmatically initialize display variables at startup so that the initial display was what I wanted, for example, values based on the day of the year value. I can't crack where to replicate this in my otherwise working Blazor webassembly app. I currently put up default values and ask the user to click a button, that calculates and updates to the values I want to display and on we go.

I would have thought there's a standard, easy way to do this, but given how Blazor pieces are constructed on the fly in order to render as web pages, maybe not? Thanks!

答:
This isn't specific to Blazor, but in any class you can create code in the constructor of your component/

Here I have a Chat component, that I break up into

```<code>Chat.razor
Chat.razor.cs
</code>```

The chat.razor.cs you create by adding a class with the same name as your component, then add the word partial to make it a partial class:

```<code>partial class Chat : IBlazorComponent, IBlazorComponentParent, IDisposable
</code>```

Note: The interfaces are just for my app, I am just showing the line with partial.
really are you need it:

```<code>partial class Chat
</code>```

Then in my constructor I created:

```<code>public Chat()
{
    // Perform initializations for this object
    Init();
}
</code>```

I just call a method, you don't have to:

My Init method:

```<code> public void Init()
 {
     // do your initializations
 }
</code>```

Or you can use OnInitializedAsync

```<code>protected override async Task OnInitializedAsync()
{
    // load the Categories (example)
    this.Categories = await HelpCategoryService.GetHelpCategoryList()
}
</code>```

Or here is another I use sometimes: OnAfterRender

```<code>protected override void OnAfterRender(bool firstRender)
{
    if (firstRender)
    {
        ...
    }
}
</code>```

Documentation for that is here:

https://learn.microsoft.com/en-us/aspnet/core/blazor/lifecycle?view=aspnetcore-3.1

Maybe that gives you some ideas. Not sure about Standard, every use case is different.

Note: I have never used Blazor Web Assembly, only server side Blazor, so not sure what is specific to WASM, but I know constructors work in any C# class.

Body:
This isn't specific to Blazor, but in any class you can create code in the constructor of your component/

Here I have a Chat component, that I break up into

Chat.razor
Chat.razor.cs

The chat.razor.cs you create by adding a class with the same name as your component, then add the word partial to make it a partial class:

partial class Chat : IBlazorComponent, IBlazorComponentParent, IDisposable

Note: The interfaces are just for my app, I am just showing the line with partial.
really are you need it:

partial class Chat

Then in my constructor I created:

public Chat()
{
    // Perform initializations for this object
    Init();
}

I just call a method, you don't have to:

My Init method:

 public void Init()
 {
     // do your initializations
 }

Or you can use OnInitializedAsync

protected override async Task OnInitializedAsync()
{
    // load the Categories (example)
    this.Categories = await HelpCategoryService.GetHelpCategoryList()
}

Or here is another I use sometimes: OnAfterRender

protected override void OnAfterRender(bool firstRender)
{
    if (firstRender)
    {
        ...
    }
}

Documentation for that is here:

https://learn.microsoft.com/en-us/aspnet/core/blazor/lifecycle?view=aspnetcore-3.1

Maybe that gives you some ideas. Not sure about Standard, every use case is different.

Note: I have never used Blazor Web Assembly, only server side Blazor, so not sure what is specific to WASM, but I know constructors work in any C# class.


问:
Heroku producing 500 error when trying to send emails
I have a Rails application on Heroku that has started to produce 500 errors, I believe, when attempting to send emails – we use the SendGrid addon.

The error that I am seeing is this:

```<code>OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (certificate has expired)
</code>```

Our certificates are managed by Heroku so I cannot see info about them in the Heroku control panel, but when I look at the certificate in Chrome it looks like they are valid until the end of July.

I have filed an issue with Heroku support, and am waiting for a response.

Update: Heroku said it was because their stack version 16 was an issue, and that I should upgrade to 18. I did that, but it did not help.

I have found that for some reason I am only apparently only getting this issue with Devise mailers.

I tested setting OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE and this solved the problem...

So now I’m not sure if Devise is doing something different than the other mailers, and if so why...

答:
It looks like you've been affected by this root certificate expiry issue:
https://news.ycombinator.com/item?id=23362759

You should confirm the version of openssl running on your Heroku dyno.

You can do that by running heroku run openssl version -a YOUR_APP_NAME.

You want version 1.1+ to avoid the above issue.

Body:
I have a Rails application on Heroku that has started to produce 500 errors, I believe, when attempting to send emails – we use the SendGrid addon.

The error that I am seeing is this:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (certificate has expired)

Our certificates are managed by Heroku so I cannot see info about them in the Heroku control panel, but when I look at the certificate in Chrome it looks like they are valid until the end of July.

I have filed an issue with Heroku support, and am waiting for a response.

Update: Heroku said it was because their stack version 16 was an issue, and that I should upgrade to 18. I did that, but it did not help.

I have found that for some reason I am only apparently only getting this issue with Devise mailers.

I tested setting OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE and this solved the problem...

So now I’m not sure if Devise is doing something different than the other mailers, and if so why...


问:
wcstombs_s(), length of converted string
```<code>errno_t wcstombs_s(
   size_t *pReturnValue,
   char *mbstr,
   size_t sizeInBytes,
   const wchar_t *wcstr,
   size_t count
);
</code>```

Microsoft VS2019's documentation says:

pReturnValue

  The size in bytes of the converted string, including the null terminator.

...

If wcstombs_s successfully converts the source string, it puts the size in bytes of the converted string, including the null terminator, into *pReturnValue (provided pReturnValue is not NULL).

cppreference.com's documentation says:

retval    -   pointer to a size_t object where the result will be stored

...

Returns zero on success (in which case the number of bytes excluding terminating zero that were, or would be written to dst, is stored in *retval)

Who is wrong ?

答:
Neither. The cppreference is referring to the standards compliant version of the function. The Microsoft documentation is referring to the version implemented in their standard library. </p>

<p>If you're using MS Visual C++, use the Microsoft docs. Otherwise, use the cppreference docs. </p>

Body:
errno_t wcstombs_s(
   size_t *pReturnValue,
   char *mbstr,
   size_t sizeInBytes,
   const wchar_t *wcstr,
   size_t count
);

Microsoft VS2019's documentation says:

pReturnValue

  The size in bytes of the converted string, including the null terminator.

...

If wcstombs_s successfully converts the source string, it puts the size in bytes of the converted string, including the null terminator, into *pReturnValue (provided pReturnValue is not NULL).

cppreference.com's documentation says:

retval    -   pointer to a size_t object where the result will be stored

...

Returns zero on success (in which case the number of bytes excluding terminating zero that were, or would be written to dst, is stored in *retval)

Who is wrong ?

Body:
Neither. The cppreference is referring to the standards compliant version of the function. The Microsoft documentation is referring to the version implemented in their standard library.

If you're using MS Visual C++, use the Microsoft docs. Otherwise, use the cppreference docs.


问:
How to open dropdown sub-menu from multi-navigation bar?
I am having trouble opening my dropdown sub-menu with CSS. I want the user to be able to open it when hovered over the corresponding  tag. I tried to make #lablinksDD open when hovered over #menuDD with #labLinksDD:hover #ddSbMenu How may I do that? I feel like I am missing something.

Code:

HTML

```<code><ul>
                    <li><a href="DD/Index.html" class="tpNavBtns">Digital Design (DD) ▾</a></li> <!--▴-->

                    <ul class="subMenu1" id="menuDD">
                        <li><a href="#" id="labLinksDD">Labs ▸</a></li> <!--◂-->

                            <ul class="drpDn-subMenu labSbMenu" id="ddSbMenu">
                                <li><a href="DD/Labs/Lab_01/LB1_WeiJianZhen_DD.html">DD Lab 1</a></li>
                                <li><a href="DD/Labs/Lab_02/LB2_WeiJianZhen_DD.html">DD Lab 2</a></li>
                                <li><a href="DD/Labs/Lab_03/Lab_3.html">DD Lab 3</a></li>
                                <!--more than 20 a tags inside lists-->
                            </ul>
</code>```

CSS

```<code>
.drpDn-subMenu {
    display: none;
    position: absolute;
    width: 200px;
    height: 500px;
    top: 0px;
    left: 164px;
    overflow-x: hidden;
    overflow-y: scroll;
    background-color: red;
    list-style-type: none;
    border-left: 1px solid rgba(120, 120, 120, 0.70);
    border-bottom: 1px solid rgba(120, 120, 120, 0.70);
}

.drpDn-subMenu a {
    display: inline-block;
    position: relative;
    padding: 20px 50px;
    width: 100%;
    height: auto;
    text-align: left;
}

#menuDD {
    top: 100%;
    left: 13.6%;
}

#menuWCP {
    top: 50px;
    left: 800px;
}

.labSbMenu {
    z-index: 3;
}

.prSbMenu {
    top: 56px;
    height: auto;
    background-color: antiquewhite;
}

</code>```

I'll also accept a Vanilla JavaScript version instead of a CSS one.

答:
Not sure that's what you're looking for, but you could use a Javascript function:</p>

```<code><li><a href="#" id="labLinksDD" onclick="showLabLinks()">Labs ▸</a></li>

<script>
        function showLabLinks() {
        document.getElementById("ddSbMenu").style.display = "block";
        }
</script>
</code>```

Body:
I am having trouble opening my dropdown sub-menu with CSS. I want the user to be able to open it when hovered over the corresponding  tag. I tried to make #lablinksDD open when hovered over #menuDD with #labLinksDD:hover #ddSbMenu How may I do that? I feel like I am missing something.

Code:

HTML

Digital Design (DD) ▾

Labs ▸

DD Lab 1

DD Lab 2

DD Lab 3

CSS

.drpDn-subMenu {
    display: none;
    position: absolute;
    width: 200px;
    height: 500px;
    top: 0px;
    left: 164px;
    overflow-x: hidden;
    overflow-y: scroll;
    background-color: red;
    list-style-type: none;
    border-left: 1px solid rgba(120, 120, 120, 0.70);
    border-bottom: 1px solid rgba(120, 120, 120, 0.70);
}

.drpDn-subMenu a {
    display: inline-block;
    position: relative;
    padding: 20px 50px;
    width: 100%;
    height: auto;
    text-align: left;
}

#menuDD {
    top: 100%;
    left: 13.6%;
}

#menuWCP {
    top: 50px;
    left: 800px;
}

.labSbMenu {
    z-index: 3;
}

.prSbMenu {
    top: 56px;
    height: auto;
    background-color: antiquewhite;
}

I'll also accept a Vanilla JavaScript version instead of a CSS one.

Body:
Not sure that's what you're looking for, but you could use a Javascript function:

<li><a href="#" id="labLinksDD" onclick="showLabLinks()">Labs ▸</a></li>

<script>
        function showLabLinks() {
        document.getElementById("ddSbMenu").style.display = "block";
        }
</script>


问:
Understanding the decompilation of an object to source code
First of all, I am a student, I do not yet have extensive knowledge about C, C ++ and assembler, so I am making a extreme effort to understand it.

I have this piece of assembly code from an Intel x86-32 bit processor.

My goal is to transform it to source code.

```<code>0x80483dc <main>:    push       ebp
0x80483dd <main+1>:  mov        ebp,esp
0x80483df <main+3>:  sub        esp,0x10
0x80483e2 <main+6>:  mov        DWORD PTR [ebp-0x8],0x80484d0
0x80483e9 <main+13>: lea        eax,[ebp-0x8]
0x80483ec <main+16>: mov        DWORD PTR [ebp-0x4],eax
0x80483ef <main+19>: mov        eax,DWORD PTR [ebp-0x4]
0x80483f2 <main+22>: mov        edx,DWORD PTR [eax+0xc]
0x80483f5 <main+25>: mov        eax,DWORD PTR [ebp-0x4]
0x80483f8 <main+28>: movzx      eax,WORD PTR [eax+0x10]
0x80483fc <main+32>: cwde
0x80483fd <main+33>: add        edx, eax
0x80483ff <main+35>: mov        eax,DWORD PTR [ebp-0x4]
0x8048402 <main+38>: mov        DWORD PTR [eax+0xc],edx
0x8048405 <main+41>: mov        eax,DWORD PTR [ebp-0x4]
0x8048408 <main+44>: movzx      eax,BYTE PTR [eax]
0x804840b <main+47>: cmp        al,0x4f
0x804840d <main+49>: jne        0x8048419 <main+61>
0x804840f <main+51>: mov        eax,DWORD PTR [ebp-0x4]
0x8048412 <main+54>: movzx      eax,BYTE PTR [eax]
0x8048415 <main+57>: cmp        al,0x4b
0x8048417 <main+59>: je         0x804842d <main+81>
0x8048419 <main+61>: mov        eax,DWORD PTR [ebp-0x4]
0x804841c <main+64>: mov        eax,DWORD PTR [eax+0xc]
0x804841f <main+67>: mov        edx, eax
0x8048421 <main+69>: and        edx,0xf0f0f0f
0x8048427 <main+75>: mov        eax,DWORD PTR [ebp-0x4]
0x804842a <main+78>: mov        DWORD PTR [eax+0x4],edx
0x804842d <main+81>: mov        eax,0x0
0x8048432 <main+86>: leave
0x8048433 <main+87>: ret
</code>```

This is what I understand from the code:

There are 4 variables:

```<code>a = [ebp-0x8] ebp
b = [ebp-0x4] eax
c = [eax + 0xc] edx
d = [eax + 0x10] eax
</code>```

Values:

```<code>0x4 = 4
0x8 = 8
0xc = 12
0x10 = 16
0x4b = 75
0x4f = 79
</code>```

Types:

```<code>char (8 bits) = 1 BYTE
short (16 bits) = WORD
int (32 bit) = DWORD
long (32 bits) = DWORD
long long (32 bit) = DWORD
</code>```

This is what I was able to create:

```<code>#include <stdio.h>
int main (void)
{
   int a = 0x80484d0;
   int b
   short c;
   int d;

   c + b?
if (79 <= al) {
instructions
} else {
instructions
}

   return 0
}
</code>```

But I'm stuck. Nor can I understand what the sentence "cmp al .." compares to, what is "al"?

How do these instructions work?

EDIT1:

That said, as you comment the assembly seems to be wrong or as someone comments say, it is insane!

The code and the exercise are from the following book called: "Reversing, Reverse Engineering" on page 140 (3.8 Proposed Exercises). It would never have occurred to me that it was wrong, if so, this clearly makes it difficult for me to learn ...

So it is not possible to do a reversing to get the source code because it is not a good assembly? Maybe I am not oppressed? Is it possible to optimize it?

EDIT2:

Hi!

I did ask and finally she says this should be the c code:

```<code>inf foo(void){
    char *string;//ebp-0x8
    unsigned int *pointerstring//[ebp-0x4]
    unsigned int *position;
    *position = *(pointerstring+0xc);
    unsigned char character;
    character=(unsigned char) string[*position];
    if ((character != 0x4)||(character != 0x4b))
    {
     *(position+0x4)=(unsigned int)(*position & 0x0f0f0f0f);
    }
    return(0);
}
</code>```

Does it have any sense at all for you?, could someone please explain this to me?
Does anyone really program like this?

Thanks very much!

答:
Your assembly is completely insane. This is roughly equivalent C:

int main() {
    int i = 0x80484d0; // in ebp-8
    int *p = &i; // in ebp-4
    p[3] += (short)p[4]; // add argc to the return address(!)
    if((char)*p != 0x4f || (char)*p != 0x4b) // always true because of || instead of &&
        p[1] = p[3] & 0xf0f0f0f; // note that p[1] is p
    return 0;
}
```

It should be immediately obvious that this is horrifically bad code that almost certainly won't do what the programmer intended.

Body:
First of all, I am a student, I do not yet have extensive knowledge about C, C ++ and assembler, so I am making a extreme effort to understand it.

I have this piece of assembly code from an Intel x86-32 bit processor.

My goal is to transform it to source code.

0x80483dc :    push       ebp
0x80483dd :  mov        ebp,esp
0x80483df :  sub        esp,0x10
0x80483e2 :  mov        DWORD PTR [ebp-0x8],0x80484d0
0x80483e9 : lea        eax,[ebp-0x8]
0x80483ec : mov        DWORD PTR [ebp-0x4],eax
0x80483ef : mov        eax,DWORD PTR [ebp-0x4]
0x80483f2 : mov        edx,DWORD PTR [eax+0xc]
0x80483f5 : mov        eax,DWORD PTR [ebp-0x4]
0x80483f8 : movzx      eax,WORD PTR [eax+0x10]
0x80483fc : cwde
0x80483fd : add        edx, eax
0x80483ff : mov        eax,DWORD PTR [ebp-0x4]
0x8048402 : mov        DWORD PTR [eax+0xc],edx
0x8048405 : mov        eax,DWORD PTR [ebp-0x4]
0x8048408 : movzx      eax,BYTE PTR [eax]
0x804840b : cmp        al,0x4f
0x804840d : jne        0x8048419
0x804840f : mov        eax,DWORD PTR [ebp-0x4]
0x8048412 : movzx      eax,BYTE PTR [eax]
0x8048415 : cmp        al,0x4b
0x8048417 : je         0x804842d
0x8048419 : mov        eax,DWORD PTR [ebp-0x4]
0x804841c : mov        eax,DWORD PTR [eax+0xc]
0x804841f : mov        edx, eax
0x8048421 : and        edx,0xf0f0f0f
0x8048427 : mov        eax,DWORD PTR [ebp-0x4]
0x804842a : mov        DWORD PTR [eax+0x4],edx
0x804842d : mov        eax,0x0
0x8048432 : leave
0x8048433 : ret

This is what I understand from the code:

There are 4 variables:

a = [ebp-0x8] ebp
b = [ebp-0x4] eax
c = [eax + 0xc] edx
d = [eax + 0x10] eax

Values:

0x4 = 4
0x8 = 8
0xc = 12
0x10 = 16
0x4b = 75
0x4f = 79

Types:

char (8 bits) = 1 BYTE
short (16 bits) = WORD
int (32 bit) = DWORD
long (32 bits) = DWORD
long long (32 bit) = DWORD

This is what I was able to create:

#include <stdio.h>
int main (void)
{
   int a = 0x80484d0;
   int b
   short c;
   int d;

   c + b?
if (79 <= al) {
instructions
} else {
instructions
}

   return 0
}

But I'm stuck. Nor can I understand what the sentence "cmp al .." compares to, what is "al"?

How do these instructions work?

EDIT1:

That said, as you comment the assembly seems to be wrong or as someone comments say, it is insane!

The code and the exercise are from the following book called: "Reversing, Reverse Engineering" on page 140 (3.8 Proposed Exercises). It would never have occurred to me that it was wrong, if so, this clearly makes it difficult for me to learn ...

So it is not possible to do a reversing to get the source code because it is not a good assembly? Maybe I am not oppressed? Is it possible to optimize it?

EDIT2:

Hi!

I did ask and finally she says this should be the c code:

inf foo(void){
    char *string;//ebp-0x8
    unsigned int *pointerstring//[ebp-0x4]
    unsigned int *position;
    *position = *(pointerstring+0xc);
    unsigned char character;
    character=(unsigned char) string[*position];
    if ((character != 0x4)||(character != 0x4b))
    {
     *(position+0x4)=(unsigned int)(*position & 0x0f0f0f0f);
    }
    return(0);
}

Does it have any sense at all for you?, could someone please explain this to me?
Does anyone really program like this?

Thanks very much!

Body:
Your assembly is completely insane. This is roughly equivalent C:

int main() {
    int i = 0x80484d0; // in ebp-8
    int *p = &i; // in ebp-4
    p[3] += (short)p[4]; // add argc to the return address(!)
    if((char)*p != 0x4f || (char)*p != 0x4b) // always true because of || instead of &&
        p[1] = p[3] & 0xf0f0f0f; // note that p[1] is p
    return 0;
}

It should be immediately obvious that this is horrifically bad code that almost certainly won't do what the programmer intended.


答:
In BDictionary<E>::removeAny, the call to ABag<KVPair<Key, E>>::removeTop wants to "return" a KVPair<Key, E>. But removeAny is only equipped to "return" an E. You cannot pass the E &returnValue argument of removeAny on to removeTop, since removeTop will want to return the whole pair and not just the value, but only the value will "fit" in the E&.

Without going into and modifying the internals of ABag, I think the best you can do is create a temporary KVPair<Key, E> "destination" in removeAny to hold the value coming from removeTop, and then pass along just the value part of that pair. This is ugly, but it works:

```<code>bool removeAny(E &returnValue) {
    KVPair<Key, E> dest;
    bool removed = dictionary->removeTop(dest);
    if(removed) returnValue = std::move(dest.value); // or however you get the value out
    return removed;
}
</code>```

Alternately, modify the signature of removeAny so that it, too, returns the entire pair.

```<code>bool removeAny(KVPair<Key, E> &dest) {
    return dictionary->removeTop(dest);
}
</code>```

This would require modifying your calling code (in bagtestmain.cpp).

Title: What is an Integer?

Body: An integer programming problem is a mathematical optimization or feasibility program in which some or all of the variables are restricted to be integers.

Body:
In BDictionary<E>::removeAny, the call to ABag<KVPair<Key, E>>::removeTop wants to "return" a KVPair<Key, E>. But removeAny is only equipped to "return" an E. You cannot pass the E &returnValue argument of removeAny on to removeTop, since removeTop will want to return the whole pair and not just the value, but only the value will "fit" in the E&.

Without going into and modifying the internals of ABag, I think the best you can do is create a temporary KVPair<Key, E> "destination" in removeAny to hold the value coming from removeTop, and then pass along just the value part of that pair. This is ugly, but it works:

bool removeAny(E &returnValue) {
    KVPair<Key, E> dest;
    bool removed = dictionary->removeTop(dest);
    if(removed) returnValue = std::move(dest.value); // or however you get the value out
    return removed;
}

Alternately, modify the signature of removeAny so that it, too, returns the entire pair.

bool removeAny(KVPair<Key, E> &dest) {
    return dictionary->removeTop(dest);
}

This would require modifying your calling code (in bagtestmain.cpp).