J2EE中那些忘却的~
1.About Struts2
1.1 The minimal required Struts 2 framework Jar files
- commons-fileupload-X.X.X.jar
- commons-io-X.X.X.jar
- commons-lang-X.X.jar
- commons-logging-X.X.X.jar
- commons-logging-api.X.X.jar
- freemarker-X.X.X.jar
- ognl-X.X.X.jar
- struts2-core-X.X.X.X.jar
- xwork-core-X.X.X.jar
- javassist-X.X.X.jar
1.2 To enable the Struts 2 framework to work with your web application you need to add a Servlet filter class and filter mapping to web.xml.
web.xml Servlet Filter
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Note the url-pattern node value is /* meaning the Struts 2 filter will be applied to all URLs for this web application.
1.3 The minimal xml configuration. Note the file name is struts.xml and it should be in the src folder (struts.xml must be on the web application's root class path).
struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <package name="basicstruts2" extends="struts-default"> <action name="index"> <result>/index.jsp</result> </action> </package> </struts>
1.4 Struts2 use flow
- Create a class to store the welcome message (the model)
- Create a server page to present the message (the view)
- Create an Action class to control the interaction between the user, the model, and the view (the controller)
- Create a mapping (struts.xml) to couple the Action class and view
2.About Log4J
2.1 Download path: http://archive.apache.org/dist/logging/log4j/
2.2 Setup a log4j.xml configuration in the src folder.
log4j.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/> </layout> </appender> <!-- specify the logging level for loggers from other libraries --> <logger name="com.opensymphony"> <level value="DEBUG" /> </logger> <logger name="org.apache.struts2"> <level value="DEBUG" /> </logger> <!-- for all other loggers log only debug and above log messages --> <root> <priority value="INFO"/> <appender-ref ref="STDOUT" /> </root> </log4j:configuration>
2021年5月26日 21:43 Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definately interested in this one. Just thought that I would post and let you know. click here
2021年5月30日 00:39
Smmvaly is the Best Cheapest wholesale SMM Reseller Panel for easy social media promotion. The main provider of Fastest TikTok Fans, Instagram followers, Facebook Likes and YouTube Views services. One Of The Best SMM Panel That Understands Your Needs & Delivers Your Concerns In On Time. Best in Market, Competitive Price. LIVE Chat Support. Wholesale smm panel
2021年5月30日 16:40 It is a fantastic post – immense clear and easy to understand. I am also holding out for the sharks too that made me laugh. MM2 value lists
2021年5月30日 17:03
This is the type of information I’ve long been trying to find. Thank you for writing this information. Black hat forum
2021年6月01日 22:36 Thankyou for this wondrous post, I am glad I observed this website on yahoo. Lifeguard classes near me
2021年6月01日 22:36 Thankyou for this wondrous post, I am glad I observed this website on yahoo. Lifeguard classes near me
2021年6月04日 23:52
You have a real talent for writing unique content. I like how you think and the way you express your views in this article. I am impressed by your writing style a lot. Thanks for making my experience more beautiful. 토토사이트
2021年6月06日 20:56 Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! check this site
2021年6月10日 17:51
Nice to read your article! I am looking forward to sharing your adventures and experiences. 바카라
2022年11月22日 05:39
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. Satta king
2022年11月26日 22:00
Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. deep web