小编Cod*_*Med的帖子

使用jstl访问url参数

我是jstl的新手,我需要帮助在jsp上获取url-string参数,该参数还包含从数据库中检索的迭代对象列表中的EL标记.有人可以告诉我如何修复下面的代码,以便下面的代码行填充我要求的实际数字${param.spid}:

<a href="create-course-summary?spid="${param.spid}>add</a>
Run Code Online (Sandbox Code Playgroud)

这是背景:

我用以下url模式调用servlet:

view-course-summaries?spid=1  
Run Code Online (Sandbox Code Playgroud)

doGet在servlet中调用以下方法:

protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
   throws ServletException, IOException {
    String spidString = req.getParameter("spid");
    Long spid = new Long(spidString);
    List<CourseSummary> coursesummaries = new CourseSummaryDAO().findAllCS(spid);
    req.setAttribute("coursesummaries", coursesummaries);
    jsp.forward(req, resp);
}
Run Code Online (Sandbox Code Playgroud)

并返回以下jsp:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="admintop.inc" %>
<table>
<tr>
  <td>Name of School (Course Provider):</td>
  <td>will go here</td>
</tr>
<tr><td colspan=2>
<a href="create-course-summary?spid="${param.spid}>add</a>
</td>
</tr>
<tr>
   <td colspan=2>
        <table>
            <tr>
                <th>Type</th>
                <th>Number</th>
                <th>id</th>
            </tr>
            <c:forEach varStatus="loopCounter" items="${coursesummaries}" var="coursesummary">
            <tr>
                <td> …
Run Code Online (Sandbox Code Playgroud)

jsp servlets jstl

8
推荐指数
1
解决办法
3万
查看次数

检查MS Access SQL语句中的空值

以下查询未返回CurrentVisitor我的ms access 2010数据库中的值:

SELECT h.ClientNumber, IIf(h.CheckoutDate=null,"Yes","") AS CurrentVisitor 
FROM VisitsTable AS h 
INNER JOIN (
    SELECT ClientNumber, MAX(LastVisitDate) AS LastVisitStart 
    FROM VisitsTable 
    GROUP BY ClientNumber)  
    AS t 
ON (h.LastVisitStart = t.LastVisitStart) AND (h.ClientNumber = t.ClientNumber);
Run Code Online (Sandbox Code Playgroud)

我认为原因是操作中的null检查If()未正确写入.谁能告诉我如何解决这个问题?

sql ms-access

8
推荐指数
1
解决办法
4万
查看次数

使用 aws sns 从 java web 应用程序发送短信

用户将在我的网络应用程序上创建一个帐户。该应用程序需要通过向用户提供的手机号码发送短信来验证用户身份。短信是一个简短的唯一代码,用户需要将其输入到网络浏览器中,以便应用程序对用户进行身份验证。

如何为此用例配置 Amazon AWS SNS?

据我所知,SNS 的工作原理是网站管理员选择一个主题topic,然后每个用户订阅该主题。然后,网站管理员以广播方式向该主题的所有订阅者发送消息。这不能满足我向每个用户发送唯一消息的要求。或者,topic为每个电话号码创建单独的电话号码将过于麻烦,更不用说在保护所有电话号码的隐私方面产生安全问题了。

可以为此用例配置 Amazon AWS SNS 吗?如果是这样,怎么办?

我正在使用Java。

amazon-web-services amazon-sns

8
推荐指数
1
解决办法
1万
查看次数

回调如何在AngularJS中调用REST服务?

我正在研究AngularJS和REST.代码示例callback在身份验证功能中重复使用该单词. 回调是JavaScript或Angular中的关键字吗?或者callback只是在此代码中创建的自定义变量?如何callback在下面的代码中工作? 谷歌搜索callback和AngularJS没有产生可用的结果. 可以在此链接中读取有问题的AngularJS模块的代码,该链接还包含示例应用程序的所有代码.

这是模块代码本身:

angular.module('auth', []).factory( 'auth',

    function($rootScope, $http, $location) {

        enter = function() {
            if ($location.path() != auth.loginPath) {
                auth.path = $location.path();
                if (!auth.authenticated) {
                    $location.path(auth.loginPath);
                }
            }                   
        }

        var auth = {

            authenticated : false,

            loginPath : '/login',
            logoutPath : '/logout',
            homePath : '/',
            path : $location.path(),

            authenticate : function(credentials, callback) {

                var headers = credentials && credentials.username ? {
                    authorization : "Basic "
                            + btoa(credentials.username + ":" …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

8
推荐指数
1
解决办法
2万
查看次数

Persistence.createEntityManagerFactory()在哪里查找持久性单元?

我正在使用eclipse.我试图调试失败,找到确实位于我的eclipse项目的目录结构中的持久性单元.

在哪里EntityManagerFactory javax.persistence.Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties)寻找持久性单元?

当我问它看起来在哪里时,我的意思是所有可能被搜索的资源,包括eclipse配置,如果找到文件就在persistence.xml中的属性,包含JAR搜索的资源等.为了探索这是如何工作的,我正在执行通过右键单击位于src/main/javaeclipse项目的root()中的Main.java类来测试程序.

答案可能有助于我弄清楚如何配置eclipse项目,以便EntityManagerFactory javax.persistence.Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties)找到持久性单元.

java eclipse persistence hibernate jpa

7
推荐指数
1
解决办法
1万
查看次数

如何自动装配这个TokenStore

如何触发此示例Spring Boot OAuth2应用程序的自动注销?

我尝试将以下代码从另一个帖子的答案中添加到应用程序demo包中的新控制器类中: authserver

package demo;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;

@Controller
public class OAuthController {
    @Autowired
    private TokenStore tokenStore;

    @RequestMapping(value = "/oauth/revoke-token", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    public void logout(HttpServletRequest request) {
        String authHeader = request.getHeader("Authorization");
        if (authHeader != null) {
            String tokenValue = authHeader.replace("Bearer", "").trim();
            OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
            tokenStore.removeAccessToken(accessToken);
        }
    }
}  
Run Code Online (Sandbox Code Playgroud)

但是当我尝试启动应用程序时,调试日志会显示以下错误,指示它不能autowire存储令牌存储:

Caused by: org.springframework.beans.factory.BeanCreationException: …
Run Code Online (Sandbox Code Playgroud)

spring spring-security autowired spring-boot spring-oauth2

7
推荐指数
1
解决办法
1万
查看次数

请求'OPTIONS/logout'与'POST/logout'不匹配

我正在通过分解此GitHub示例中的三个互连应用程序来学习Spring Cloud和Spring OAuth2 .当我打开了/oauth/revoke-token在终端authserver应用程序,然后调用它的ui应用http://localhost:9999/uaa/logout,调试日志为authserver应用程序提供了以下错误信息,而拒绝退出请求:

Request 'OPTIONS /logout' doesn't match 'POST /logout
Run Code Online (Sandbox Code Playgroud)

应用程序调用注销功能时,需要对示例GitHub应用程序中的代码进行哪些具体更改才能使全局注销成功?uihello.js


初始努力:


到目前为止我所做的更改包括:

将以下@Bean定义添加到AuthserverApplication.java:

@Bean
public TokenStore tokenStore() {return new InMemoryTokenStore();}
Run Code Online (Sandbox Code Playgroud)

demoauthserver应用程序包中添加以下控制器类:

@Configuration
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    TokenStore tokenStore;

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.tokenStore(tokenStore);
    }

    @RequestMapping(value = "/oauth/revoke-token", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    public void logout(HttpServletRequest …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot spring-cloud spring-oauth2

7
推荐指数
1
解决办法
4759
查看次数

将自定义UserDetailsS​​ervice添加到Spring Security OAuth2应用程序

如何添加自定义UserDetailsService下面这个春天的OAuth2样

默认默认user值在应用程序passwordapplication.properties文件中定义authserver.

不过,我想以下自定义添加UserDetailsServicedemo包中的authserver应用程序用于测试目的:

package demo;

import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.provisioning.UserDetailsManager;
import org.springframework.stereotype.Service;

@Service
class Users implements UserDetailsManager {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        String password;
        List<GrantedAuthority> auth = AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER");
        if (username.equals("Samwise")) {
            auth = AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_HOBBIT");
            password = "TheShire";
        }
        else if (username.equals("Frodo")){
            auth = AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_HOBBIT");
            password = "MyRing";
        }
        else{throw …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot spring-security-oauth2 spring-oauth2

7
推荐指数
3
解决办法
1万
查看次数

删除 node-role.kubernetes.io/master:NoSchedule 污点

我可以输入什么 CLI 命令来node-role.kubernetes.io/master:NoSchedule从 Kubernetes 集群的主节点中删除污点?

以下命令失败:

[lnxcfg@ip-10-0-0-193 ~]$ kubectl taint nodes $(kubectl get nodes --selector=node-role.kubernetes.io/master | awk 'FNR==2{print $1}') key:node-role.kubernetes.io/master:NoSchedule-
error: invalid taint effect: node-role.kubernetes.io/master, unsupported taint effect
Run Code Online (Sandbox Code Playgroud)

如下所示,我可以通过使用以下命令成功获取主节点的名称,该命令也嵌入在上述失败命令中:

[lnxcfg@ip-10-0-0-193 ~]$ kubectl get nodes --selector=node-role.kubernetes.io/master | awk 'FNR==2{print $1}'
ip-10-0-0-193.us-west-2.compute.internal
Run Code Online (Sandbox Code Playgroud)

这是一个 AWS Linux 2 节点,托管单个主 Kubernetes 集群的主节点。

kubernetes kubectl kubeadm

7
推荐指数
3
解决办法
2万
查看次数

使用充气城堡创建Thunderbird可用的公共PGP密钥

PGP使用org.bouncycastle.openpgp.PGPKeyRingGenerator创建了公钥和私钥.在进行GregS建议的更改后,公钥是一个.asc文件,私钥是一个.skr文件.我需要首先将公钥分发给Thunderbird用户,然后再分发给Outlook和其他电子邮件客户端的用户.我阅读了这些用于在thunderbird中接收公钥的指令,但是这些指令仅指定了.asc扩展而没有指定.asc文件的内容/结构.

如何进行设置,以便我的(修改后的?)代码创建一个公钥,Thunderbird的远程用户可以使用该公钥发送加密的电子邮件,然后由我的私钥解密,也可以由(修改后的?)代码创建下面? 接受的答案将包括分步说明,不仅用于对下面的代码进行任何必要的更改,而且还用于设置每个远程Thunderbird用户以利用下面生成的公钥来发送可以被解密的电子邮件.我的应用中的私钥,由下面的(修改后的?)代码创建.

这是我的密钥生成代码的第一个草稿:

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Date;

import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle.bcpg.sig.Features;
import org.bouncycastle.bcpg.sig.KeyFlags;
import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
import org.bouncycastle.openpgp.PGPEncryptedData;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPKeyRingGenerator;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator;
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyEncryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
import org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair;  

public class RSAGen {
    public static void main(String args[]) throws …
Run Code Online (Sandbox Code Playgroud)

java email encryption bouncycastle pgp

6
推荐指数
1
解决办法
7374
查看次数