Heim > php教程 > php手册 > Using PHP as a Spring MVC View via Quercus(转)

Using PHP as a Spring MVC View via Quercus(转)

WBOY
Freigeben: 2016-06-13 10:17:38
Original
1239 Leute haben es durchsucht

原贴:

http://blog.caucho.com/2009/04/14/using-php-as-a-spring-mvc-view-via-quercus/

 

This week, I’ve been prepping for a talk on Quercus in which I promised to show a demo of Spring MVC using a PHP view.  So that means that I actually had to do it.   Turns out it was quite easy and PHP makes for a very nice, compact view technology for Spring MVC.  This is a bit of tease since the code for this won’t go out until at least next week, but since a number of people have been asking for this a while, I thought I’d give a preview…

 

First, let me show how it looks by using the sample “ImageDB” application that ships with Spring.  Here’s a screenshot of the app in action:

 

Basically, you upload an image to the page and it keeps track of what you’ve uploaded in a database.  Here are the JSP and PHP views side-by-side:

                } %>

"1" cellspacing="0" cellpadding="5"> "imageUpload" method="post" encType="multipart/form-data">  

     

"clearDatabase">Clear database

                } ?>

"1"

cellspacing="0" cellpadding="5"> "imageUpload" method="post" encType="multipart/form-data">        

"clearDatabase">Clear database

"false" %> "java.util.List,                  java.util.Iterator,                  org.springframework.samples.imagedb.ImageDescriptor" %>

 

List images = (List) request.getAttribute("images"); for (Iterator it = images.iterator(); it.hasNext();) { ImageDescriptor image = (ImageDescriptor) it.next(); %> "1" cellspacing="0" cellpadding="5">  

"10%">Name () %> 
"2">Using PHP as a Spring MVC View via Quercus(转)"imageContent?name=" height="100">
Description (() %>) () %> 
"10%">Name "text" name="name">
Content "file" name="image">
Description
"2">"submit" value="Upload image">

 

foreach ($images as $image) { ?> "1" cellspacing="0" cellpadding="5">  

"10%">Name = $image->getName() ?> 
"2">Using PHP as a Spring MVC View via Quercus(转)"imageContent?name== $image->getName() ?>" height="100">
Description (= $image->getDescriptionLength() ?>) = $image->getShortDescription() ?> 
"10%">Name "text" name="name">
Content "file" name="image">
Description
"2">"submit" value="Upload image">
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage