Can i use JSP with Angular2?

2019-09-17 19:52发布

问题:

I necessary to use JAVA and Angular2. Can i use JSP with Angular2 ?

i got error message

app.component.ts

@Component({
    ...
    templateUrl: '../views/sidebar.jsp', 
    ...
})

sidebar.jsp

<li>
    <a href="<c:url value="/logout" />">
         <i class="fa fa-sign-out fa-fw"></i> 
         Logout
    </a>
</li>

Error

EXCEPTION: Template parse errors:
Unexpected closing tag "a" ("></li>
            <li><a href="<c:url value="/logout" />"><i
                    class="fa fa-sign-out fa-fw"></i> Logout[ERROR ->]</a></li>
        </ul>
    </div>
"): AppComponent@58:45

====================================================================

edited

<li><a href="<c:url value="/logout" />">

to

<li><a href='<c:url value="/logout" />'>

however JSTL tag wasn't compile :(

回答1:

Yes off course we can use JSP with angular2. I don't know much about JSP usage with angular2, but yes found some mistakes in your code,

  1. We can't use " " in " " we should have to use either ' ' in " " or vice versa.

  2. In angular2 we use routerLink instead of href.

  3. <a> is not self closing tag i think you make it in your code. so throwing error Unexpected closing tag "a"



标签: angular