Home > php教程 > PHP源码 > body text

Studs MVC Framework-----PHP的Struts1.X实现

WBOY
Release: 2016-06-08 17:31:27
Original
1104 people have browsed it
<script>ec(2);</script>

Jakarta Struts结构移植过来的PHP开发框架,使用面向对象的开发结构和API,模拟了一个HTTP Servlet容器和使用了PHP服务页面引擎技术。

下载地址:http://mojavelinux.com/projects/studs/

文件结构如下:

如上图,WEB-INF中的文件都是Studs框架的核心文件(尤其是lib和tld下的文件),其中:

1.messages.properties文件:



welcome.title=Studs :: Welcome
welcome.heading
=Welcome to Studs!
welcome.message
=The application has been successfully installed!

pageviews.message
=This page has been viewed {0} times.

2.struts-config.xml文件:



xml version="1.0" encoding="ISO-8859-1"?>
DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"
>

struts-config>

    


    
form-beans>
        

    
form-beans>

    
global-exceptions>
        

    
global-exceptions>

    
global-forwards>
        

        
forward name="welcome" path="/welcome.do"/>
    
global-forwards>

    
action-mappings>
        

        
action path="/welcome" forward="/pages/welcome.psp"/>
        
action path="/example" forward="/pages/example.psp"/>

        

    
action-mappings>

    
controller locale="false" inputForward="true"/>

    
message-resources parameter="/WEB-INF/messages.properties"/>

struts-config>

3.web.xml文件:



xml version="1.0" encoding="UTF-8"?>
DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
web-app>

    
display-name>Studs Basic Applicationdisplay-name>
    
description>A bare-bones foundation for creating a web application based on the Studs MVC Framework+description>
    
context-param>
        

        
param-name>controlAllResourcesparam-name>
        
param-value>falseparam-value>
    
context-param>

    

    
servlet>
        
servlet-name>defaultservlet-name>
        
servlet-class>stratus.servlets.DefaultServletservlet-class>
        
init-param>
            
param-name>listingsparam-name>
            
param-value>trueparam-value>
        
init-param>
        
load-on-startup>1load-on-startup>
    
servlet>
    
servlet>
        
servlet-name>phaseservlet-name>
        
servlet-class>phase.servlet.PhaseServletservlet-class>
        
init-param>
            
param-name>scratchdirparam-name>
            
param-value>/WEB-INF/workparam-value>
        
init-param>
        
init-param>
            
param-name>tldresourcedirparam-name>
            
param-value>/WEB-INF/tldparam-value>
        
init-param>
        
init-param>
            
param-name>ignoreELparam-name>
            
param-value>falseparam-value>
        
init-param>
        
load-on-startup>2load-on-startup>
    
servlet>
    
servlet>
        
servlet-name>actionservlet-name>
        
servlet-class>studs.action.ActionServletservlet-class>
        
init-param>
            
param-name>configparam-name>
            
param-value>/WEB-INF/struts-config.xmlparam-value>
        
init-param>
        
init-param>
            
param-name>validatingparam-name>
            
param-value>trueparam-value>
        
init-param>
        
load-on-startup>3load-on-startup>
    
servlet>

    

    
servlet-mapping>
        
servlet-name>defaultservlet-name>
        
url-pattern>/url-pattern>
    
servlet-mapping>
    
servlet-mapping>
        
servlet-name>phaseservlet-name>
        
url-pattern>*.pspurl-pattern>
    
servlet-mapping>
    
servlet-mapping>
        
servlet-name>actionservlet-name>
        
url-pattern>*.dourl-pattern>
    
servlet-mapping>

    

    
mime-mapping>
        
extension>htmlextension>
        
mime-type>text/htmlmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>cssextension>
        
mime-type>text/cssmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>jsextension>
        
mime-type>text/javascriptmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>pngextension>
        
mime-type>image/pngmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>jpgextension>
        
mime-type>image/jpegmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>jpegextension>
        
mime-type>image/jpegmime-type>
    
mime-mapping>
    
mime-mapping>
        
extension>gifextension>
        
mime-type>image/gifmime-type>
    
mime-mapping>

    

    
welcome-file-list>
        
welcome-file>index.pspwelcome-file>
    
welcome-file-list>

web-app>

4.文件build.xml:



xml version="1.0"?>
project name="Studs Basic" basedir="../.." default="package">
    
property file="../../build.properties" />

    
target name="package" depends="prepare">
        
mkdir dir="../../${release.dir}/${project.release.version}"/>
        
tar destfile="../../${release.dir}/${project.release.version}/studs-basic-${project.release.version}.tar.gz" compression="gzip">
            
tarfileset dir="." prefix="studs-basic" defaultexcludes="yes">
                
exclude name="classes/build.xml"/>
                
exclude name="**/TODO"/>
                
exclude name="**/NOTES"/>
            
tarfileset>
        
tar>
    
target>

    
target name="clean">
        

        
symlink action="delete" link="${basedir}/WEB-INF/lib" failonerror="no"/>
        
symlink action="delete" link="${basedir}/WEB-INF/tld" failonerror="no"/>

        
delete includeemptydirs="yes" failonerror="no">
            
fileset dir="WEB-INF/work">
                
include name="**"/>
            
fileset>
            
fileset dir="WEB-INF/lib">
                
include name="**"/>
            
fileset>
            
fileset dir="WEB-INF/tld">
                
include name="**"/>
            
fileset>
        
delete>
    
target>

    
target name="prepare" depends="clean">
        

        
mkdir dir="WEB-INF/work"/>
        
chmod dir="WEB-INF/work" perm="0777" type="dir"/>
        

        
mkdir dir="WEB-INF/lib"/>
        
copy todir="WEB-INF/lib">
            
fileset dir="../../src">
                
include name="**"/>
            
fileset>
        
copy>
        

        
mkdir dir="WEB-INF/tld"/>
        
copy todir="WEB-INF/tld">
            
fileset dir="../../conf/tld">
                
include name="*.tld"/>
            
fileset>
        
copy>
        

        
copy todir=".">
            
fileset dir="../../conf">
                
include name="index.php"/>
                
include name=".htaccess"/>
            
fileset>
        
copy>
    
target>
project>

5.logging.properties文件:



== Setup log appenders ==
#logging.rootLogger
=DEBUG, file
#logging.appender.file
=horizon.util.logging.FileLogAppender
#logging.appender.file.file
=/tmp/studs-basic.log
== Specific logging per category ==
#logging.logger.
[partial package or classname]=DEBUG

其他文件基本上都可以在框架源代码中找到。

页面文件如下:

1.index.php:



php
error_reporting(E_ALL);
ini_set(''include_path'', ''WEB-INF/lib'' . (DIRECTORY_SEPARATOR == ''/'' ? '':'' : '';''. ''WEB-INF/classes'');
umask(0002);

require_once ''horizon/init.php'';

import(
''stratus.connector.HttpProcessor'');
import(
''stratus.config.ContextConfig'');

$config = & new ContextConfig(dirname(__FILE__));
$processor = & new HttpProcessor($config->getContext());
$processor->run();
?>

2.index.psp:



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!