PDA

View Full Version : Spring MVC +quercus php


bill.liao@gmail.com
02-13-2012, 09:47 PM
I use spring mvc and quercus php as view

<beans:bean class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<beans: property name="prefix" value="/WEB-INF/views/" />
<beans: property name="suffix" value=".php" />
</beans:bean>

in Controller:

@RequestMapping( value = "/list" )
public String list(
@RequestParam(value = "page", required = false) Integer page,
Model model) {
int pageNum = page != null ? page : DEFAULT_PAGE_NUM;
Page<Person> paging = personService.findAll(pageNum, DEFAULT_PAGE_SIZE);
model.addAttribute("page", paging);
return "/person/list";
}

View file: list.php

how can I get Object from controller at list.php?

bill.liao@gmail.com
02-15-2012, 05:09 PM
I use spring mvc, quercus php as view

Controller pass the modelandview to php

Person is a java entity

in my list.php file:

$request = quercus_servlet_request();
$person= $request->getAttrubute("person");
var_dump($person);


but I get string like

resource(Person[id=90, name=name90, age=91])


how can I get a normal php array

nam
02-25-2012, 11:57 PM
It looks like your Person object is not an array class that quercus recognizes, so it didn't convert it to a php array automatically.

And in this context, resource(Person[id=90, name=name90, age=91]) means it's a java object and you can call any of its methods from php.