小编Ham*_*aee的帖子

react routing能够处理不同的url路径,但tomcat返回404不可用的资源

我是新手,reactjs我有一个小项目reactjs可以玩并学习它.我需要输入基于url路径显示的标题类型.所以以下是我的index.js处理路由:

 const history = useRouterHistory(createHistory)({
     basename: '/test'
})
class Tj extends React.Component {

render() {

    return (
        <Router history={history}>
            <Route path={"/"} component={Bridge} >
                <IndexRoute component={Home} />
                <Route path={"user"} component={T} />
                <Route path={"home"} component={Home} />
            </Route>
            <Route path={"/t/"} component={Bridge2} >
                <IndexRoute component={T} />
                <Route path={"contact"} component={Home} />
            </Route>
        </Router>
    );
}
}
render(
<Provider store={store}>
    <Tj/>
</Provider>,
window.document.getElementById('mainContainer'));
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我使用test作为根目录,并根据用户的url输入决定我应该使用哪个头.这里还有Bridge2.js:

export class Bridge2 extends React.Component {
render() {

    return (
        <div>
            <div className="row">
                <Header2/> …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router

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

无法仅使用cloudformation创建IAM策略

我遇到了在cloudformation中创建IAM策略的问题.但是当我运行它时,我得到组,角色,用户需要的错误:

这是我的代码:

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation Template IAM Groups and Policies",
"Resources": {
    "PolicyAutoScalingLimitedOperation": {
        "Type": "AWS::IAM::Policy",
        "Properties": {
            "PolicyName": "AutoScaling-Limited-Operation",
            "PolicyDocument": {
                "Statement": [{
                        "Effect": "Allow",
                        "Action": [
                            "dynamodb:*"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Effect": "Allow",
                        "Action": [
                            "cloudwatch:PutMetricData"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Effect": "Allow",
                        "Action": [
                            "xray:PutTraceSegments",
                            "xray:PutTelemetryRecords"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Effect": "Allow",
                        "Action": [
                            "s3:Get*",
                            "s3:List*",
                            "s3:PutObject"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Effect": "Allow",
                        "Action": [
                            "logs:PutLogEvents",
                            "logs:CreateLogStream"
                        ],
                        "Resource": "arn:aws:logs:*:*:log-group:/aws/elasticbeanstalk*"
                    }, …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation amazon-iam

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

无法通过 cloudformation 设置 cognito 用户池客户端的属性

我正在尝试通过 cloudformation 运行 congnito 并且一切正常,但是 cognito 中有如下部分:

在此处输入图片说明

如您所见,有“启用身份提供商”部分,但我找不到可以将其设置为 cloudformation 中的 Cognito 用户池的位置!

我试过这个属性,但它说不支持。

SupportedIdentityProviders
Run Code Online (Sandbox Code Playgroud)

这是我的用户池客户端代码:

  UserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
  ClientName: !Sub ${project}-client
  ExplicitAuthFlows:
   - ADMIN_NO_SRP_AUTH
   - USER_PASSWORD_AUTH
  GenerateSecret: false
  UserPoolId: !Ref UserPool
  RefreshTokenValidity: 30
Run Code Online (Sandbox Code Playgroud)

这是我的用户池:

  UserPool:
Type: "AWS::Cognito::UserPool"
Properties:
  UserPoolName: !Sub ${project}-user-pool-test
  AutoVerifiedAttributes:
    - email
  UsernameAttributes:
    - email
  MfaConfiguration: "OFF"
  LambdaConfig:
    CustomMessage:
      Fn::ImportValue: !Sub ${project}-${EnvironmentApp}-lambda-cognito-custom-message-post
  Policies:
    PasswordPolicy:
      MinimumLength: !Ref MinimumLength
      RequireLowercase: !Ref RequireLowercase
      RequireNumbers: !Ref RequireNumbers
      RequireSymbols: !Ref RequireSymbols
      RequireUppercase: !Ref RequireUppercase
  Schema:
    -
        AttributeDataType: String
        DeveloperOnlyAttribute: false
        Mutable: true …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation aws-opsworks amazon-cognito

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

弹性beanstalk无法创建

我正在尝试使用安装在其上的java运行beanstalk非常快.

所以我所做的只是打开beanstalk控制台,在创建应用程序后创建环境,在环境预配置中我选择了java.

然后在单击"创建"按钮后出现一些错误:

Creating security group named: awseb-e-rnwzmmymhx-stack-AWSEBSecurityGroup-SXHGXGDOF5PN failed Reason: Resource creation cancelled

Stack named 'awseb-e-rnwzmmymhx-stack' aborted operation. Current state: 'CREATE_FAILED' Reason: The following resource(s) failed to create: [AWSEBEIP, AWSEBSecurityGroup].
Run Code Online (Sandbox Code Playgroud)

或者更完整的错误堆栈如下: 在此输入图像描述

我从未附加任何EIP,我只是让beanstalk处理它.问题是什么?

我应该配置其他什么吗?(任何想法都表示赞赏.)

或者更好地问这样:我们是否需要将EIP附加到beanstalk以使其工作或者使用rout53有一个工作量?

amazon-web-services amazon-elastic-beanstalk

6
推荐指数
2
解决办法
6417
查看次数

当我尝试在 aws 弹性搜索中注册存储库时出现错误“不允许跨账户传递角色”

我在将存储库注册到 aws 弹性搜索时遇到问题。这是我用来执行此操作的链接:

[ http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html#es-managedomains-snapshot-registerdirectory][1]

正如链接中提到的,我复制了以下代码并运行它:

from boto.connection import AWSAuthConnection
Run Code Online (Sandbox Code Playgroud)

类 ESConnection(AWSAuthConnection):

def __init__(self, region, **kwargs):
    super(ESConnection, self).__init__(**kwargs)
    self._set_auth_region_name(region)
    self._set_auth_service_name("es")

def _required_auth_capability(self):
    return ['hmac-v4']

if __name__ == "__main__":

client = ESConnection(
        region='us-east-1',
        host='search-weblogs-etrt4mbbu254nsfupy6oiytuz4.us-east-1.es.example.com',
        aws_access_key_id='my-access-key-id',
        aws_secret_access_key='my-access-key', is_secure=False)

print 'Registering Snapshot Repository'
resp = client.make_request(method='POST',
        path='/_snapshot/weblogs-index-backups',
        data='{"type": "s3","settings": { "bucket": "es-index-backups","region": "us-east-1","role_arn": "arn:aws:iam::123456789012:role/TheServiceRole"}}')
body = resp.read()
print body
Run Code Online (Sandbox Code Playgroud)

我还调整了安全性和帐户 ID 以及……以适应我的情况。当我运行它时,我收到以下错误:

b'{"Message":"Cross-account pass role is not allowed."}'
Run Code Online (Sandbox Code Playgroud)

无论我使用什么都在同一个帐户中,我还向我的用户添加了以下内联策略

{
"Version": "2012-10-17",
"Statement": {
    "Effect": "Allow",
    "Action": "iam:PassRole",
    "Resource": "arn:aws:iam::xxxxxxxxxx:role/myrole"
}
Run Code Online (Sandbox Code Playgroud)

}

任何人都可以帮助我的问题是什么?

amazon-web-services amazon-iam amazon-cloudsearch

5
推荐指数
0
解决办法
2320
查看次数

Cloudformation不支持在apigateway中创建vpc链接

在aws api网关中有一个名为API Link的部分,我可以手动设置它. 在此输入图像描述

问题是我在cloudformation文档中找不到关于如何通过api网关上的云形成创建vpc链接的任何部分.是不是因为cloudformation不支持,或者我错过了它?

amazon-web-services aws-cloudformation aws-api-gateway

5
推荐指数
2
解决办法
1731
查看次数

componentWillMount 未在渲染前完成

我在 reactjs 中遇到一些困难。据我所知,componentWillMount 是在组件呈现之前使用 ajax 调用加载数据的地方。我有一个简单的项目,它使用加载的数据填充面板堆栈并将其显示在板上。然而,来自 ajax 调用的数据在渲染组件之前没有设置,这导致使用空数组渲染板。以下是我的完整来源:

import  React from "react";
export class Panel extends  React.Component{
render() {
    return (
    <div>
        <div className="row panel">
            <div className="col-sm-12 header">sfsfsf</div>
            <div className="col-sm-12 body">fsdfsfs</div>
            <div className="col-sm-12 footer">fasfaf</div>
        </div>
    </div>
    );
   }
   }
Run Code Online (Sandbox Code Playgroud)

作为问题根源的 Board 类如下:

import  React from "react";
 import {Panel} from "./Panel";
 export class Board extends  React.Component{
 constructor(props){
    super();
    this.state={news: []};
}
componentWillMount(){
    this.state={news: []};
    $.ajax({
        url: "http://localhost:3003/json.txt",
        dataType: 'json',
        cache: false,
        success: function(data) {
            var arr=[];
            for (var key in data) …
Run Code Online (Sandbox Code Playgroud)

reactjs react-jsx

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

React Link无法正确重定向

我正在使用Link in react来重定向到外部链接,如下所示:

<div className="btn-footer-padd">
    <Link className="career-btn sourceSansPro-sanSerif"
        target="_blank" 
        to="https://google.com"
    >Careers</Link>
</div>
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试它时,重定向如下:

http://myweburl/http://https://google.com
Run Code Online (Sandbox Code Playgroud)

我想要的是重定向到这个:

http://https://google.com
Run Code Online (Sandbox Code Playgroud)

任何的想法?

reactjs react-router react-router-dom

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

如何将模板添加到cloudformation中APIgateway的body映射模板(在integrationResponse中)

我正在使用 api 网关,并且在我的集成响应的正文映射模板中,我有:

#set ($errorMessageObj = $util.parseJson($input.path('$.errorMessage')))
#set ($bodyObj = $util.parseJson($input.body))

 {
  "searchObjects":"$input.body",
  "statusCode":"$errorMessageObj.statusCode",
  "message":"$errorMessageObj.message"

 }
Run Code Online (Sandbox Code Playgroud)

现在,在我的代码的 api 网关部分中,我有:

GetMethod:
  Type: AWS::ApiGateway::Method
  DependsOn: APIGatewayToLambdaPermission
  Properties:
    AuthorizationType: NONE
    HttpMethod: GET
    Integration:
      Type: AWS
      IntegrationHttpMethod: POST
      Uri:
        Fn::Join:
        - ''
        - - 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/'
          - Fn::ImportValue: !Sub ${project}-${EnvironmentApp}-lambda-es-
            search
          - "/invocations"
      IntegrationResponses:
      - StatusCode: 200
        ResponseParameters:
          method.response.header.Access-Control-Allow-Origin: "'*'"
Run Code Online (Sandbox Code Playgroud)

我不知道如何将其添加到我的云结构中:

    #set ($errorMessageObj = $util.parseJson($input.path('$.errorMessage')))
#set ($bodyObj = $util.parseJson($input.body))

 {
  "searchObjects":"$input.body",
  "statusCode":"$errorMessageObj.statusCode",
  "message":"$errorMessageObj.message"

 }
Run Code Online (Sandbox Code Playgroud)

这是我的 api 网关设置:

在此输入图像描述

任何想法?

amazon-web-services aws-cloudformation aws-api-gateway

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

cloudformation 未在 api 网关中附加请求的路径参数

我正在尝试在 cloudformation 中创建 api 网关。一切都很好,除了当我指定路径参数 url 时,我可以在创建的 api 网关中看到它。这是我的 cfn 代码:

GetMethod:
Type: AWS::ApiGateway::Method
Properties:
  AuthorizationType: NONE
  HttpMethod: GET
  Integration:
    Type: HTTP
    IntegrationHttpMethod: GET
    Uri:
      Fn::Join:
      - ''
      - - "http://"
        - Fn::ImportValue: !Sub ${project}-${EnvironmentApp}-bn-user-endpoint-url
        - "/users"
        - "/{users}"
    IntegrationResponses:
    - StatusCode: 200
      ResponseParameters:
        method.response.header.Access-Control-Allow-Origin: "'*'"
      ResponseTemplates:
        application/json: ''
    RequestTemplates:
      application/json: ''
  RequestParameters:
    method.request.path.users: true
  ResourceId: !Ref UsersPathParam
  RestApiId:
    Ref: RestApi
  MethodResponses:
  - StatusCode: 200
    ResponseParameters:
        method.response.header.Access-Control-Allow-Origin: true
Run Code Online (Sandbox Code Playgroud)

如果您在上面的代码中注意到我特别要求名为 users 的路径参数:

RequestParameters:
    method.request.path.users: true
Run Code Online (Sandbox Code Playgroud)

此外,您可以看到创建的 API 网关没有在附加图像中设置路径参数。有任何想法吗?

支持图片[1]

amazon-web-services aws-cloudformation aws-api-gateway

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