GVKun编程网logo

在生产抛出文件中找不到哈希路由错误

35

如果您想了解在生产抛出文件中找不到哈希路由错误的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析Android风味–在R文件中找不到符号变量、c#–使用jquery和handler(ashx)在

如果您想了解在生产抛出文件中找不到哈希路由错误的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析Android风味 – 在R文件中找不到符号变量、c# – 使用jquery和handler(ashx)在上传文件中找不到’错误’、Castor-XML jar文件中找不到方法错误、Chevrotain npm 模块在角度构建后抛出“错误:终端令牌名称: 在规则中找不到:<版本>”的各个方面,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

在生产抛出文件中找不到哈希路由错误

在生产抛出文件中找不到哈希路由错误

好的时机。过去几天我在同一条船上,只是想通了。除非,我没有像您一样更改为HashRouter。相反,我保留了所有路由内容,就像默认的electron-react-boilerplate一样,如ConnectedRouter。也许任何一种方法都可以。

https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues/1853#issuecomment-674569009

__dirname仅适用于开发人员。我使用DebugTron来检查每个资源正在加载哪些URL,它是file://path/to/app.asar/something。然后我想出了通往阿萨尔(Asar)的途径。无论应用程序位于何处,这对我在dev和prod中都有效。您还需要设置nodeIntegration: true。在macOS上进行了测试。

const electron = require("electron")
//...
win.loadURL(`file://${electron.remote.app.getAppPath()}/app.html#/yourroutename`)

更完整的示例,以防万一有人想知道如何加载另一个页面并将参数传递给它:

import routes from '../constants/routes.json'
const electron = require("electron")
// ...
var win = new BrowserWindow({
  width: 400,height: 400,webPreferences: { nodeIntegration: true }
})
win.loadURL(`file://${electron.remote.app.getAppPath()}/app.html#${routes["ROOM"]}?invitationCode=${encodeURIComponent(code)}`)
win.show()

并在组件中加载路线:

const queryString = require('query-string')
// ...
constructor(props) {
  super(props)
  const params = queryString.parse(location.hash.split("?")[1])
  this.invitationCode = params.invitationCode
}

Android风味 – 在R文件中找不到符号变量

Android风味 – 在R文件中找不到符号变量

我有两种口味 – paidapp和freeapp.
唯一的区别是,paidapp在MainActivity上还有一个按钮,比如说“付费按钮”.
paidapp有自己的布局,按钮 android:id =“@ id / paidbutton”,freeapp的布局没有这个按钮.

在代码我用这个:

if (BuildConfig.FLAVOR.equals("paidapp")) {
            View paidbutton = findViewById(R.id.paidbutton);
            paidbutton.setonClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    //...
                }
            });
}

但我有一个错误找不到findViewById(R.id.paidbutton)中的符号变量;

如何在不克隆MainActivity.java的情况下解决这个问题?

EDIT1 – 添加更多代码示例:

摇篮:

productFlavors {
    paidapp {
    }
    freeapp {
    }
}

/app/src/main/res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/goNext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Go next" />

</LinearLayout>

/app/src/paidapp/res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/goNext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Go next" />

    <Button
        android:id="@+id/paidbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="See more" />


</LinearLayout>

/app/src/main/java/company/com/myapplication/MainActivity.java

package company.com.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        View goNext = findViewById(R.id.goNext);
        goNext.setonClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"goNext click",Toast.LENGTH_SHORT).show();
            }
        });

        if (BuildConfig.FLAVOR.equals("paidapp")) {
            View paidbutton = findViewById(R.id.paidbutton);
            paidbutton.setonClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(MainActivity.this,"paidapp click",Toast.LENGTH_SHORT).show();
                }
            });
        }
    }

}

EDIT2 – 我找到了一些使用反射的解决方法,但仍在寻找正常的解决方案:

而不是View paidbutton = findViewById(R.id.paidbutton);我用过View paidbutton = findViewById(getIdFromrId(“paidbutton”));

其中getIdFromrId是:

private int getIdFromrId(String idName) {
    int id = 0;
    try {
        Class c = R.id.class;
        Field field = c.getField(idName);
        id = field.getInt(null);
    } catch (Exception e) {
        // do nothing
    }
    return id;
}

解决方法

如果你在freeapp产品风格中根本没有paybutton布局元素,你可以在freeapp product flavor文件夹中的一个资源xml文件中声明相应的id项.例如,创建包含以下内容的文件src / freeapp / res / values / ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="paidbutton" type="id"/>
</resources>

在执行此操作之后,编译公共代码没有任何问题,因为将为两种产品风格定义符号R.id.paidbutton. findViewById()调用将返回paidapp构建中的真实布局元素,并将在freeapp构建中返回null.

c# – 使用jquery和handler(ashx)在上传文件中找不到’错误’

c# – 使用jquery和handler(ashx)在上传文件中找不到’错误’

UploadHandler.ashx.cs

public class UploadHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        try
        {
            string dirFullPath = HttpContext.Current.Server.MapPath("~/Uploader/");
            string[] files;
            int numFiles;
            files = System.IO.Directory.GetFiles(dirFullPath);
            numFiles = files.Length;
            numFiles = numFiles + 1;
            string str_image = "";

            foreach (string s in context.Request.Files)
            {
                HttpPostedFile file = context.Request.Files[s];
                string fileName = file.FileName;
                string fileExtension = file.ContentType;

                if (!string.IsNullOrEmpty(fileName))
                {
                    fileExtension = Path.GetExtension(fileName);
                    str_image = "MyPHOTO_" + numFiles.ToString() + fileExtension;
                    string pathToSave_100 = HttpContext.Current.Server.MapPath("~/Uploader/") + str_image;
                    file.SaveAs(pathToSave_100);
                }
            }
            //  database record update logic here  ()

            context.Response.Write(str_image);
        }
        catch (Exception ac)
        {

        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

JsCode

/Image Upload code
function sendFile(file) {

    var formData = new FormData();
    formData.append('file',$('#f_UploadImage')[0].files[0]);

    $.ajax({
        url: 'UploadHandler.ashx',type: 'POST',data: formData,cache: false,processData: false,contentType: false,success: function(result) {
            if (result != 'error') {
                var my_path = "Uploader/" + result;
                $("#myUploadedImg").attr("src",my_path);
            }
        },error: function(err) {
            alert(err.statusText);
        }
    });
}


function callImgUploader() {
    var _URL = window.URL || window.webkitURL;
    $("#f_UploadImage").on('change',function() {

        var file,img;
        if ((file = this.files[0])) {
            img = new Image();
            img.onload = function() {
                sendFile(file);
            };
            img.onerror = function() {
                alert("Not a valid file:" + file.type);
            };
            img.src = _URL.createObjectURL(file);
        }
    });
}

注意:我的Aspx页面是不同的文件夹和Image Folder和UploadHandler.ashx.cs是路径文件夹错了吗?

运行ajax请求后每次给出Not-Found错误怎么能修复它.

谢谢.

解决方法

您没有提到您正在使用哪个上传控件,我假设它是服务器端,您需要按如下方式访问它

更改

$('#f_UploadImage')

$('#<%= f_UploadImage.ClientID %>')

Castor-XML jar文件中找不到方法错误

Castor-XML jar文件中找不到方法错误

此特定错误有两个原因:

1-您缺少具有此方法的jar文件(这可能不是您遇到的问题,正如您所说的那样,当您查看反编译的jar时可以看到它)

2-您的依赖项中有2个或更多jar,实际上它正在查看没有所需方法的jar。

您应如何处理如下:

  • 打开思路,打开pom.xml文件
  • 打开“依赖关系继承关系”视图,搜索org.codehaus.castor或castor-xml,查看您有多少个不同版本。

如果大于1,并且其中一些包含在另一个jar中,则可以在pom.xml中使用它删除不需要的版本。

如果您喜欢命令行,则可以使用mvn依赖项:tree

希望这对您有所帮助。

-编辑-

您的代码正在使用1.3.2依赖项。怎么样?您可以下载castor-xml.1.3.2.jar并将其解压缩并查看Marshaller。您会看到getResolver()方法没有任何参数,因此您获得了NoMethodFound。

´´´

/**
 * Returns the ClassDescriptorResolver for use during marshalling
 *
 * @return the ClassDescriptorResolver
 * @see #setResolver
 */
public XMLClassDescriptorResolver getResolver() {


} 

´´´

因此,您需要在依赖关系层次结构中进行查找,将包括此1.3.2 jar并将其排除在外。

pom.xml中的一个排除方法示例:

<dependency>
  <groupId>sample.group.which.has.castor.in.it</groupId>
  <artifactId>artifactor.which.has.castor.in.it</artifactId>
  <version>1.0</version>
  <scope>compile</scope>
  <exclusions>
    <exclusion>  <!-- declare the exclusion here -->
      <groupId>org.codehaus.castor</groupId>
      <artifactId>castor-xml</artifactId>
      <version>1.3.2</version>
    </exclusion>
  </exclusions> 
</dependency>
<dependency> <!-- add proper dependency also,as it is needed -->
    <groupId>org.codehaus.castor</groupId>
    <artifactId>castor-xml</artifactId>
    <version>1.4.1</version>
</dependency>

Chevrotain npm 模块在角度构建后抛出“错误:终端令牌名称:<n> 在规则中找不到:<版本>”

Chevrotain npm 模块在角度构建后抛出“错误:终端令牌名称: 在规则中找不到:<版本>”

如何解决Chevrotain npm 模块在角度构建后抛出“错误:终端令牌名称:<n> 在规则中找不到:<版本>”?

我正在使用 THREE.js,尤其是依赖于 chevrotain.js 的 VrmlLoader,一切都在本地运行良好,但在我使用此配置运行我的 angular 构建之后:

        "build": {
          "configurations": {
            "dev": {
              "fileReplacements": [],"optimization": true,"outputHashing": "all","sourceMap": false,"extractCss": true,"namedChunks": false,"extractLicenses": true,"vendorChunk": false,"buildOptimizer": true,"budgets": [
                {
                  "type": "initial","maximumWarning": "10mb","maximumError": "10mb"
                },{
                  "type": "anyComponentStyle","maximumWarning": "12kb","maximumError": "15kb"
                }
              ]
            }
          }
        }

Chevrotain 模块在尝试使用 THREE.js VrmlLoader 加载 Vrml 文件时抛出“错误:终端令牌名称: 在规则中未找到:”。我用的chevrotain版本是最后一个,根据我的package.json : "chevrotain": "^9.0.2"。

根据chevrotain.io website,这个错误从 6.0.0 开始不会再发生了。

我可以在上面的构建配置中设置 "optization": false 后使其工作。这个解决方案并不令人满意,我觉得这里缺少一些明显的东西。我会很感激这方面的所有想法。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

关于在生产抛出文件中找不到哈希路由错误的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Android风味 – 在R文件中找不到符号变量、c# – 使用jquery和handler(ashx)在上传文件中找不到’错误’、Castor-XML jar文件中找不到方法错误、Chevrotain npm 模块在角度构建后抛出“错误:终端令牌名称: 在规则中找不到:<版本>”等相关内容,可以在本站寻找。

本文标签: