将jsp页面移动到Angular 7

问题描述 投票:0回答:1

我目前正在研究一个Angular项目,以将我们现有的应用程序从jsp更新为Angular7。但是,有些jsp页面由于需要传统支持而无法完全转换为html。

所以我需要知道如何将它们移动到角度。我的想法是将jsp页面及其所有的css复制到角度组件。

The jsp code is something like below
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ include file="/WEB-INF/jsp/cwf/common/include.jsp"%>
<link
    href="<%=request.getContextPath()%>/static/css/insurance/insureServ.css"
    rel="stylesheet" type="text/css" />
<%-- START CONTAINER --%>
<div id="container">

    <%-- START HEADER --%>
    <div id="header">

        <div class="headerLogoProd">&nbsp;</div>
        <%-- ///Use  class="headerLogoPSE" or class="headerLogoProd" depending on desired logo /// --%>
        <div class="floatleft">
            Welcome,
            <c:out default="Guest" value="${name}" />
        </div>
        <div
            style="border-style: none; float: left; font-size: 1.5em; font-family: sans-serif; color: #FF800D">PRODUCTION</div>
        <div class="floatright">
            <a target="_blank"
                href="http://test.net">Contact
                Us</a> | <a href="mailto:[email protected]">Feedback</a> | <a
                target="_blank" href="http://fakeurl.net">ABDHome</a>
        </div>

    <%-- START Icon Elements --%>
        <c:forEach items="${userTamRoles}" var="userTamRole">
            <c:if test="${userTamRole eq 'ATH'}">
                <div class="icon_element"
                    onMouseOver="this.className='icon_elementHover'"
                    onMouseOut="this.className='icon_element'">
                    <a target="_blank" href="fake.do"><img
                        src="static/images/ins/asdf.gif" alt=""
                        width="90" height="70" vspace="5" align="left"><br />
                        <h3>Inquiry</h3> View transactions for the
                         Transfer Service.</a>
                </div>
            </c:if>
///More html code similar to above here


</div>
<%-- END CONTAINER --%>
<script type="text/javascript">
var url = window.location.href;
var n = url.indexOf("https://pott");
if(n > -1) {
    document.getElementById("ddd").style.display = "none";
    } 
</script>

现在使用spring的当前代码具有如下所示的webserivce

@RequestMapping(value = "/inland", method = RequestMethod.GET)
public ModelAndView insuranceLandingpage(HttpServletRequest request) throws Exception {

    // get the user name and set it in the session, we will use this in the jsp
    String name = cuoUser.getUserFirstName() + " " + cuoUser.getUserLastName();
    request.getSession().setAttribute("name", name);

    // get entitled products /Roles from TAM
    List<String> user= this.headerUtil.getRolesFromReqHeader(request, userId);
    request.setAttribute("userTamRoles", user);
    return new ModelAndView(".abc.portal.insurance");
}

并且servlet.xml已经定义了映射

**

<definition name=".abc.portal.insurance"
        template="/WEB-INF/jsp/tiles/insurance/inlanding.jsp">
        <put-attribute name="body"
            value="/WEB-INF/jsp/tiles/insurance/inlanding.jsp" />

**

现在有了角度,我无法使用模型和视图,因此我将不得不重构Web服务以返回json对象。但是,如何呈现JSP页面?我可以复制整个jsp页面并将其粘贴到有角度的组件中。但是我该如何渲染请求参数呢?<c:forEach items="${userTamRoles}" var="userTamRole"> or <c:out default="Guest" value="${name}" />进入角组件?会将其识别为jsp语法吗?

java angular jsp spring-rest
1个回答
0
投票

我自己解决了这个问题。而不是在角度上重新呈现jsp页面,我只是在我的servlet xml文件中添加了一个视图解析器。

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>org.springframework.web.servlet.view.tiles2.TilesView</value>
    </property>
    </bean>
        <bean id="tilesConfigurer"
            class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/config/spring-tiles.xml</value>
                    <!-- <value>/WEB-INF/config/cwf/tiles-defs-cwf.xml</value> -->
                </list>
            </property>
        </bean>
© www.soinside.com 2019 - 2024. All rights reserved.