开发者

Mixing Spring MVC with inline PHP

开发者 https://www.devze.com 2023-03-28 01:10 出处:网络
I was wondering if it\'s possible to write PHP code inline within开发者_运维百科 Spring MVC pages.

I was wondering if it's possible to write PHP code inline within开发者_运维百科 Spring MVC pages.

Something like

<html xmlns:jsp="http://java.sun.com/JSP/Page" 
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:tiles="http://tiles.apache.org/tags-tiles"
      xmlns:spring="http://www.springframework.org/tags"
      xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" >

    <jsp:output doctype-root-element="HTML" doctype-system="about:legacy-compat" />

    <jsp:directive.page contentType="text/html;charset=UTF-8" />  
    <jsp:directive.page pageEncoding="UTF-8" /> 

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=8" />    
        <title><tiles:insertAttribute name="title"/></title>
        <util:load-scripts />
        <spring:message code="application_name" var="app_name" />

    </head>

    <body style="background-image: url(${resources}/images/Main_bg.jpg);">
        <div id="wrapper">
                    <lang:PHP>
                        require_once(somephpfile.php);
                        ...

I have a massive piece of legacy PHP code that I want to integrate into an even bigger system I'm building, the new system is written with Spring and Spring MVC.


Yes, you can. For instance by running php from within the JVM using Quercus and you probably need to write some sort of custom tag.


This library allows you to use php in spring as dynamic language and template engine. https://github.com/PaulWeb/quercusspring

0

精彩评论

暂无评论...
验证码 换一张
取 消