簡體   English   中英

為什么在嘗試從表單中獲取數據時會出現此錯誤?

[英]why do i get this error when trying to get data from a form?

這是我得到的錯誤:

14:06:00,355 ERROR [JsonFilter] java.lang.NoSuchMethodException: byte.<init>(java.lang.String)

我有一個帶有輸入文件的基本上傳表單:

<form method='post' enctype='multipart/form-data'>
<table>
<input type='file' name='logo'>
</table>
</form>

當我提交時,它調用一個 setter servlet,在 servlet 內部有一個 extract() 來獲取數據:

if (fileUp.getContent("compLogo") != null) 
        {
            record.compLogo = fileUp.getContent("compLogo").getData();
        } else
            System.out.println("logo was null!");

        return record;  

但問題是,它甚至在得到確切的 function 之前就拋出了這個錯誤,我在它之前放了很多系統輸出,所以我會知道這些功能是如何移動的。

15:07:06,915 ERROR [JsonFilter] java.lang.NoSuchMethodException: byte.<init>(java.lang.String)
javax.servlet.ServletException: java.lang.NoSuchMethodException: byte.<init>(java.lang.String)
    at com.pinksheets.common.web.req.HttpExtractor.getObject(HttpExtractor.java:160)
    at com.pinksheets.common.web.req.HttpExtractor.extract(HttpExtractor.java:88)
    at com.pinksheets.common.web.servlet.FetcherServlet.doGet(FetcherServlet.java:52)
    at com.pinksheets.common.web.servlet.FetcherServlet.doPost(FetcherServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.pinksheets.common.web.filter.RoleAuthFilter.doFilter(RoleAuthFilter.java:78)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.pinksheets.common.web.filter.UserAuthFilter.doFilter(UserAuthFilter.java:49)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.pinksheets.common.web.filter.JsonFilter.doFilter(JsonFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.jboss.web.tomcat.service.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:135)
    at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:94)
    at org.jboss.web.tomcat.service.session.LockingValve.invoke(LockingValve.java:62)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodException: byte.<init>(java.lang.String)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getConstructor(Unknown Source)
    at com.pinksheets.common.web.req.HttpExtractor.getObject(HttpExtractor.java:142)
    ... 37 more

這將生成 html 代碼

EditSplashPageDOM.generate = function (value, callback)
{
    var elem, output = document.createElement('form');
    output.myValue = value;
    output.myCallback = callback;
    output.method = 'post';
    output.enctype = 'multipart/form-data';
    output.onsubmit = function(ev) { callback.handleSubmit(value, this); return false; };
    output.appendChild(InputField.genHidden ('id', value.id));
    output.appendChild(InputField.genHidden ('name', value.name));

    var div, p;
    output.appendChild(div = document.createElement('div'));
    div.appendChild(p = document.createElement('p'));
    p.innerHTML = 'The Splash Page list all the information for the current ad. You may update to change the Splash Page.<br /><span class="footnote">*The info shown are data of the latest ad and the proper format.*</span>';

    var table = document.createElement('table');
    output.appendChild(table);
    table.className = 'detail';

    this.createRow(table, 'Company Symbol', 'compSymbol', value.compSymbol, 100, 50);
    this.createRow(table, 'Company Sec Id', 'secId', value.secId, 100, 50);

    this.createFileRow(table, 'Company Logo', 'compLogo', 100, 47); //this is for input the file

    row = table.insertRow (table.rows.length);
    cell = row.insertCell(0);
    cell.colSpan = 2;
    cell.className = 'detailAction'
    cell.appendChild(elem = InputField.genSubmit('Submit', 'Insert New Ad'));

    return output;
}

這是提交 function

EditSplashPageSimple.prototype.handleSubmit = function(value, form)
{

    value.compLogo = form.compLogo.value;
    value.compPAL = form.compPAL.value;
    value.compUrl = form.compUrl.value;

    if(value.compLogo == null)
        window.alert("comp logo is null");
    else 
        window.alert("logo is " + value.compLogo);

    var me = this;
    me.caller.setSplashPage(value);
                    {
                        handleRequestData : function(status) {
                            window.alert('Splash Page is successfully updated with new company ' + value.compSymbol);
//                          me.callback.handleAddition(value);
                        },
                        handleRequestError : function(error) {
                            // Only deal with validation exceptions.
                        if (!error.isValidationException) {
                            window.alert('Sorry, there was an error while trying to add the new information. Please double check the data.');
                            throw error;
                        }

                        window.alert(error.message);
                        var e;
                        if (error.field && (e = form.elements[error.field])) {
                            window.alert('error.field error idk');
                            e.focus();
                        }
                    }
                    });
}

當提交它會調用servlet

System.out.println("now to extract the content of the file and set it to the logo var");
            SplashPage record = (new SplashPageLogoAdapter(request)).extract();

extract() 與我發布的相同

看起來這個com.pinksheets API 假設它在某個時候遇到的 class 將有一個采用String的構造函數; 當它發現有問題的 class 是byte時(即, java.lang.Byte.TYPE ,它沒有這樣的構造函數)你得到一個異常。

我想看看com.pinksheets.common.web.req.HttpExtractor.getObject()的來源; 這就是你要看到發生了什么的地方。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM