中国建设银行网站开通短信,做网站还是软件,中国公司网站建设,山东食品行业网站模板前面已经准备好了Struts-2.3.15#xff0c;现在就可以直接搭建Struts2的工程了。前面http://blog.csdn.net/huangchnegdada/article/details/9179041有对Struts-2.3.15的准备工作的详述。 首先打开MyEclispe新建一个Web Project#xff0c;名字就叫Struts2_0100_Introduction…前面已经准备好了Struts-2.3.15现在就可以直接搭建Struts2的工程了。前面http://blog.csdn.net/huangchnegdada/article/details/9179041有对Struts-2.3.15的准备工作的详述。 首先打开MyEclispe新建一个Web Project名字就叫Struts2_0100_Introduction接下来就是配置Struts2的框架 然后解压E:\Study Tools\Struts2\struts-2.3.15\apps\下的struts2-blank.war 里面有struts的最基本的配置首先找到E:\Study Tools\Struts2\struts-2.3.15\apps\struts2-blank\WEB-INF下面的web.xml文件将其拷贝到工程下的WEB-INF下面。web.xml文件中的代码如下 ?xml version1.0 encodingUTF-8?
web-app idWebApp_9 version2.4 xmlnshttp://java.sun.com/xml/ns/j2ee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsdfilterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mappingwelcome-file-listwelcome-filehello.jsp/welcome-file/welcome-file-list/web-app然后将E:\Study Tools\Struts2\struts-2.3.15\apps\struts2-blank\WEB-INF\classes下的struts.xml文件考到工程的src文件夹中。 最后工程的结构如下 struts中的文件代码如下 ?xml version1.0 encodingUTF-8 ?
!DOCTYPE struts PUBLIC-//Apache Software Foundation//DTD Struts Configuration 2.3//ENhttp://struts.apache.org/dtds/struts-2.3.dtdstruts!-- constant namestruts.enable.DynamicMethodInvocation valuefalse /constant namestruts.devMode valuetrue /package namedefault namespace/ extendsstruts-defaultdefault-action-ref nameindex /global-resultsresult nameerror/error.jsp/result/global-resultsglobal-exception-mappingsexception-mapping exceptionjava.lang.Exception resulterror//global-exception-mappingsaction nameindexresult typeredirectActionparam nameactionNameHelloWorld/paramparam namenamespace/example/param/result/action/packageinclude fileexample.xml/--!-- 此段代码非常关键它可以让你在修改代码后不需要重新启动服务器 --constant namestruts.devMode valuetrue /package namedefault namespace/ extendsstruts-defaultdefault-action-ref nameindex /!-- 全局的错误页面 --global-resultsresult nameerror/error.jsp/result/global-resultsglobal-exception-mappingsexception-mapping exceptionjava.lang.Exception resulterror//global-exception-mappingsaction namehello_strutsresult/hello.jsp/result/action/package!-- Add packages here --/struts将此项目部署起来后在Web Brower中输入http://localhost:8080/Struts2_0100_Introduction/hello_struts后会出现下面结果就说明成功了。 转载于:https://www.cnblogs.com/dyllove98/p/3157177.html