当前位置:编程学习 > JAVA >>

混血儿新生命--Java+PHP整合

最近才有时间处理此事,将此设想应用到现实应用程序中。  下面从两个方面讲解如何开发与发布。
示例:讲解java+php 开发模式,以菜单管理为例。
示例如下:
一:java 结构代码
java开发结构图如下:

java 开发结构图

java 程序代码请看在下面上传文件,由于上传文件不能大于2M,所以用到的lib 没有上传,如需求,可留邮箱给我,我发给大家。
注:PHP和Java各有其语言内部定义的数据类型,当PHP数据传送到Java,或Java数据传送到PHP时,LAJP在内部自动地、准确地对他们进行转换,程序员无需进行任何的解码工作
二:java 应用程序发布
将编译后的文件放到LAJP 目录下:我的文件目录: E:\lajp-10.05\test_service\ecard
如下图所示:

发布目录

三:php 结构代码
<?php
class Menu extends CI_Controller{
 
 function __construct(){
  parent::__construct();
  $this->load->model('system/menu_model');
 }
 
 function index(){
  $condition = array();
  $condition['menu_id'] = $this->uri->segment(4,0);
  $condition['path'] = $this->input->post('path');
  $condition['start'] = $this->input->post('start');
  $condition['id'] = $this->input->post('id');
  $condition['order'] = $this->input->post('order');
  $condition['isfresh'] = $this->input->post('isfresh');
  $condition['visible'] = $this->input->post('visible');
  $condition['defaultselect'] = $this->input->post('defaultselect');
  $condition['name'] = $this->input->post('name');
  $condition['parentid'] = $this->input->post('parent_id');
  $condition['numPerPage'] = $this->input->post('numPerPage') ? $this->input->post('numPerPage') : 20;
  $condition['orderField'] = $this->input->post('orderField') ? $this->input->post('orderField') : 'SMT_PARENT_ID';
  $condition['pageNum'] = $this->input->post('pageNum') ? $this->input->post('pageNum') : 1;
  $data = array();
  $allmenus = $this->menu_model->getMenus();
  $this->load->library('smart_tree');
  $options = array(
   'index'   => 1,
   'type'   => 0,
   'self'    => 1,
   'hreffromdb' => 0,
   'relfromdb'  => 0,
   'rel'   => 'system/menu/index',
   'href'   => 'system/menu/index/',
   'hrefuseid'  => 1,
   'title'   => '菜单管理'
  );
  $data['allmenus'] = $this->smart_tree->getTrees($allmenus, $options);
  $data['menus'] = $this->menu_model->getMenusVoByCondition($condition);
  $data['total'] = $this->menu_model->getCount($condition);
  $data['condition'] = $condition;
  $this->load->view('system/menu/index.phtml', $data);
 }
 
 function add(){
  $data['menus'] = $this->menu_model->getMenus();
  $this->load->view('system/menu/add.phtml',$data);
 }
 
 function insert(){
  $vo = newObject('ecard_sys_menus_vo_MenusVo');
  $vo->name = (string)$this->input->post('name');
  $vo->parentid = (int)$this->input->post('parent_id');
  $vodefaultselect = (int)$this->input->post('defaultselect');
  $vo->visible = (int)$this->input->post('visible');
  $vo->isfresh = (int)$this->input->post('isfresh');
  $vo->desc = (string)$this->input->post('desc');
  $vo->path = (string)$this->input->post('path');
  $vo->start = (int)$this->input->post('start');
  $vo->order = (int)$this->input->post('order');
  $vo->cuser = 1;
 
  if($this->menu_model->insert($vo)){
   $reback = array("statusCode"=>"200","message" => "添加成功","navTabId" => "system/menu/index", "callbackType" => "closeCurrent","forwardUrl" => "" );
  }else{
   $reback = array("statusCode"=>"300","message" => "添加失败","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }
  echo json_encode($reback);
 }
 
 function edit(){
  $menu_id = $this->uri->segment(4,0) or exit('菜单不存在');
  $data['menu'] = $this->menu_model->getMenusVoById($menu_id) or exit('菜单不存在');
  $data['pmenu'] = $this->menu_model->getMenusVoById($data['menu']['parentid']) or exit('菜单不存在');
  $this->load->view('system/menu/edit.phtml',$data);
 }
 
 function update(){
  $vo = newObject('ecard_sys_menus_vo_MenusVo');
  $vo->id = (int)$this->input->post('id');
  $vo->name = (string)$this->input->post('name');
  $vo->path = (string)$this->input->post('path');
  $vo->parentid = (int)$this->input->post('parent_id');
  $vo->order = (int)$this->input->post('order');
  $vo->start = (int)$this->input->post('start');
  $vo->defaultselect = (int)$this->input->post('defaultselect');
  $vo->visible = (int)$this->input->post('visible');
  $vo->isfresh = (int)$this->input->post('isfresh');
  $vo->desc = (string)$this->input->post('desc');
  $vo->uuser = 1;
  if($this->menu_model->update($vo)){
   $reback = array("statusCode"=>"200","message" => "编辑成功","navTabId" => "system/menu/index", "callbackType" => "closeCurrent","forwardUrl" => "" );
  }else{
   $reback = array("statusCode"=>"300","message" => "编辑失败","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }
  echo json_encode($reback);
 }
 
 function delete(){
  $ids = $this->input->post('ids');
  if(!$ids){
   $ids = $this->uri->segment('4',0) or exit('缺少参数');
  }
  if($thi

补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,