小编bur*_*ete的帖子

在ASP.NET中使用自定义MembershipProvider而不使用Login控件

我们有一个自定义MembershipProviderASP.NET.现在有两种可能的方案可以验证用户:

  1. 用户通过login.aspx输入用户名/密码登录页面.我使用了Login控件并将其与MyMembershipProvider.这工作得非常好.

  2. 身份验证令牌通过查询字符串中的某个URL从不同的网站传递.为此,我有一个重载MembershipProvider.Validate(string authenticationToken),实际上验证用户.在这种情况下,我们无法使用Login控件.现在如何MembershipProvider在不实际使用Login控件的情况下使用相同的方法验证用户?我试图Validate手动调用,但这不是用户签名.

这是我正在使用的代码片段

if (!string.IsNullOrEmpty(Request.QueryString["authenticationToken"])) {
    string ticket = Request.QueryString["authenticationToken"];
    MyMembershipProvider provider = Membership.Provider as MyMembershipProvider;
    if (provider != null) {
        if (provider.ValidateUser(ticket))
            // Login Success
        else
            // Login Fail
    }
}
Run Code Online (Sandbox Code Playgroud)

asp.net authentication

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

自定义jQuery验证.addMethod

我有一个表格,以最小/最大长度为基础验证邮政编码.我需要将所有国家/地区的拉链最小值设为5位数除了澳大利亚之外需要为4.以下是我遇到的问题:

$.validator.addMethod(
    "AusZip",
    function(value, element) {
        if ($("#Country").val("Aus") && ("#PostalCode").length < 4)) {
        return false;
    } else return true;
},
"Australian Zip Code Must Be at least 4 Digits");
Run Code Online (Sandbox Code Playgroud)

然后在规则中

rules: {
    PostalCode: {
        required: true,
        minlength: 5 //for all countries except AUS
        AusZip: true // for Aus
    }
}
Run Code Online (Sandbox Code Playgroud)

长度不是要走的路吗?

validation jquery

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

映射值是应该以常量还是枚举声明?

我看到这遍布整个代码库:

@RequestMapping(value = "myValue")
Run Code Online (Sandbox Code Playgroud)

我更喜欢使用这样的东西:

@RequestMapping(value = Constants.myValue)
Run Code Online (Sandbox Code Playgroud)

它似乎使用实际的String值@RequestMapping而不是常量来打破DRY .但这是一个很好的代码实践吗?我应该使用枚举吗?我可能需要Constants.myValue在代码库中的其他地方使用.

java enums spring dry spring-mvc

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

Amazon Elastic Load Balancer is not closing the connection to the server

I have an EC2 instance with Apache as a reverse proxy and ffserver as a streaming server. There is an ELB (Classic) in front of the EC2 instance which works as an SSL termination point.

Apache configuration is rather simple:

<Location "/mp3/">
    ProxyPass http://127.0.0.1:8081/ DisableReuse=On KeepAlive=Off
    ProxyPassReverse http://127.0.0.1:8081/
    SetEnv force-proxy-request-1.0.1
    SetEnv proxy-nokeepalive 1
</Location>
Run Code Online (Sandbox Code Playgroud)

ffserver is used to stream live audio over the Internet. In ffserver's settings there is a MaxBandwidth option (default 1000). This setting become a …

apache amazon-web-services ffserver amazon-elb

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

尝试设置列表时键入typeMismatch.java.util.List

我试图将a设置List<Long>为Java对象。

设置功能为:

ResponseEntity<String> response = bcInsertService.addNewClip(new PrmBcClipInsert()
    .setTags(Arrays.asList(new Long[]{5L, 3L}))
);
Run Code Online (Sandbox Code Playgroud)

而对象是

public class PrmBcClipInsert implements Serializable {

    @ApiModelProperty(required = true)
    private List<Long> tags;

    public List<Long> getTags() {
        return tags;
    }

    public PrmBcClipInsert setTags(List<Long> tags) {
        this.tags = tags;
        return this;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是BcInsertService:

public class BcInsertService extends RestTemplate {
    private static final Logger log = LoggerFactory.getLogger(BcInsertService.class);

    public ResponseEntity<String> addNewClip(PrmBcClipInsert prmBcClipInsert) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        MultiValueMap<String, Object> map= new LinkedMultiValueMap<String, Object>();
        HttpEntity<MultiValueMap<String, Object>> request = …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

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

如何将日语时代日期字符串值解析为LocalDate和LocalDateTime

如何LocalDate/LocalDateTime通过Java 8 DateTime API 将日语时代日期字符串输入解析为?

日本日历日期示例;

??23?11?29?
??22?5?3?
??23?3?11????14?46?
??5?1?11?
Run Code Online (Sandbox Code Playgroud)

java datetime internationalization datetime-format java-8

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

如何在Java DateTime API中使用日语数字解析日期字符串

问了[ 如何将日语时代日期字符串值解析为LocalDate和LocalDateTime ]之后,
我对以下情况感到好奇;

?????????????
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以将日语数字解析为日语日历字符(本质上是日语日期)的顶部LocalDate?仅使用Java DateTime API。我不想修改输入的String值,而只想使用API​​来处理识别。

java datetime internationalization datetime-format java-8

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

Lambda表达式,如何在对象内搜索?

我开始喜欢Lambda的表达,但我正在努力通过这面墙:

public class CompanyWithEmployees {
    public CompanyWithEmployees() { }
    public Company CompanyInfo { get; set; }
    public List<Person> Employees { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的搜索:

List<CompanyWithEmployees> companiesWithEmployees = ws.GetCompaniesWithEmployees();
CompanyWithEmployees ces = companiesWithEmployees
        .Find(x => x.Employees
        .Find(y => y.PersonID == person.PersonID));
Run Code Online (Sandbox Code Playgroud)

所以,我想获得具有我正在寻找的那个Person(Employee)的Object"CompanyWithEmployees",但我得到" 不能隐含地将'Person'转换为'bool') "这是正确的,但如果我'我没有传递Person对象,第一个Find怎么执行?

c# lambda

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

用于Maven构建Spring Boot产品的Java编译器版本

在这里,它说Spring Boot 1.5.2.RELEASE需要Java 7或更高版本; 和Java 1.6作为默认编译器级别.

那么这种差异会导致问题吗?

spring-boot

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

Spring Boot Actuator'http.server.requests'指标最大时间

我有一个Spring Boot应用程序,并且正在使用Spring Boot Actuator和Micrometer来跟踪有关我的应用程序的指标。我特别关注“ http.server.requests”指标和MAX统计信息:

{
    "name": "http.server.requests",
    "measurements": [
        {
            "statistic": "COUNT",
            "value": 2
        },
        {
            "statistic": "TOTAL_TIME",
            "value": 0.079653001
        },
        {
            "statistic": "MAX",
            "value": 0.032696019
        }
    ],
    "availableTags": [
        {
            "tag": "exception",
            "values": [
                "None"
            ]
        },
        {
            "tag": "method",
            "values": [
                "GET"
            ]
        },
        {
            "tag": "status",
            "values": [
                "200", 
                "400"

            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我认为MAX统计信息是执行一个请求的最长时间(因为我已经发出了两个请求,所以这是对其中一个请求进行较长时间处理的时间)。

每当我通过任何标签过滤指标时,例如 localhost:9090/actuator/metrics?tag=status:200

{
        "name": "http.server.requests",
        "measurements": [
            {
                "statistic": "COUNT",
                "value": 1
            },
            {
                "statistic": "TOTAL_TIME",
                "value": 0.029653001
            },
            {
                "statistic": …
Run Code Online (Sandbox Code Playgroud)

spring metrics spring-boot spring-boot-actuator micrometer

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