关于java:我的javascript文件出错

Error in my javascript file

码:

1
  <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

错误信息:

Multiple markers at this line

  • Syntax error on tokens, delete these tokens
  • Syntax error on tokens, ( expected instead

码:

1
var tabMessages = new Array();

错误信息:

Syntax error, insert")" to complete Expression

我的JS档案:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

var tabMessages = new Array();

tabMessages['errors.invalid']='<bean:message key="errors.invalid" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.maxlength']='<bean:message key="errors.maxlength" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.minlength']='<bean:message key="errors.minlength" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.range']='<bean:message key="errors.range" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.required']='<bean:message key="errors.required" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.byte']='<bean:message key="errors.byte" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.date']='<bean:message key="errors.date" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.double']='<bean:message key="errors.double" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.float']='<bean:message key="errors.float" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.integer']='<bean:message key="errors.integer" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.long']='<bean:message key="errors.long" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.short']='<bean:message key="errors.short" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.creditcard']='<bean:message key="errors.creditcard" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.email']='<bean:message key="errors.email" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.numeric']='<bean:message key="errors.numeric" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.filetype']='<bean:message key="errors.filetype" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.accord.nonvalide']='<bean:message key="affichagePaa.erreur.accord.nonvalide" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.telephone']='<bean:message key="errors.telephone" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.incorrectYear']='<bean:message key="error.incorrectYear" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';


tabMessages['errors.dateCumulAnnuelDepassee']='<bean:message key="declaration.saisieCARealise.validationCumulAnnuel.possibleALaBonneDate.erreur" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.dateCumulAnnuelEnCours']='<bean:message key="declaration.saisieCARealise.validationCumulAnnuel.dateOK.erreur" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.dateCumulAnnuelNonAtteinte']='<bean:message key="declaration.saisieCARealise.validationCumulAnnuel.dateDepassee.erreur" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['errors.cumulAnnuelDejaValide']='<bean:message key="declaration.saisieCARealise.validationCumulAnnuel.dej?Valider.erreur" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';

tabMessages['negociation.suppression.ristourne']='<bean:message key="negociation.suppression.ristourne" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['changement.champApplication.ristourne']='<bean:message key="negociation.AjoutRistourne.changement.champApplication.ristourne" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['matrice.suppression.familleaSuivre']='<bean:message key="matrice.suppression.familleaSuivre" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';

tabMessages['alerte.suppression.simple']='<bean:message key="alerte.suppression.simple" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';
tabMessages['alerte.suppression.complexe']='<bean:message key="alerte.suppression.complexe" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';

tabMessages['cumul.annuel.temporaire']='<bean:message key="cumul.annuel.temporaire" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';

tabMessages['calcul.retrocession.type.retrocession.differente']='<bean:message key="calcul.retrocession.type.retrocession.differente" arg0="{0}" arg1="{1}" arg2="{2}" arg3="{3}" arg4="{4}" />';


function getMessage(key, arg0, arg1, arg2, arg3, arg4) {
    var res = tabMessages[key];
    if (arg0 != undefined) {
        res = res.replace(/\{0\}/g, arg0);
    }
    if (arg1 != undefined) {
        res = res.replace(/\{1\}/g, arg1);
    }
    if (arg2 != undefined) {
        res = res.replace(/\{2\}/g, arg2);
    }
    if (arg3 != undefined) {
        res = res.replace(/\{3\}/g, arg3);
    }
    if (arg4 != undefined) {
        res = res.replace(/\{4\}/g, arg4);
    }
    return res;
}

enter image description here

怎么了 ..?


混合jsp和JS可以和/或将产生意想不到的结果。 一种方法是在一个地方收集所有与JSP相关的变量,并将非JSP代码分解为另一个纯/静态JavaScript文件。