Asked my classmates now javaweb mainstream framework is what. He said the basic framework is ssh,struts2+spring+hibernate, popular is Ssm,springmvc+spring+mybatis, originally planned to learn Struts1 framework, so do not learn, first learn Struts2, The first is Eclipse configuration Struts2.
First, download Struts2
Download the Struts2 package from http://struts.apache.org/download.cgi#struts25101, here I choose the download of min
Second, import Struts2
After download, unzip all the files under Lib and copy them to the STRUTS2 project you have created.
Three, STRUT2 configuration
1. Create the Struts.xml file under SRC, configure the following in XML, the <! introduced in XML DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.5//en"
"Http://struts.apache.org/dtds/struts-2.5.dtd", this DTD is used to verify the XML content format, if the lack of nodes, will be in the DTD and things do not go, and thus error, here also note that the root node is <struts></struts>, I forgot to gargan the node when I configured it today.
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public " -//apache software foundation//dtd Struts Configuration 2.5//en " http://struts.apache.org/dtds/struts-2.5.dtd" ><struts> <packageextends= "Struts-default" > <default- Action-ref name= "Hello"/> <action name= "Hello" > <result>/hello.jsp</result> </action> </Package ></struts>
2. The web-inf/web.xml is configured as follows, here the filter and filter-mapping are one by one corresponding, with the respective filter-name corresponding, I began to configure the time to define two Filter:struts-execute, Struts-prepare but only defined a filter-mapping:struts-prepare, in fact, the two filter class can be together, Use the following Org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter class.
<filter> <filter-name>struts-prepare</filter-name> <filter-class> org.apache.struts2.dispatcher.filter.strutsprepareandexecutefilter</filter-class> </ filter> <filter-mapping> <filter-name>struts-prepare</filter-name> < url-pattern>/*</url-pattern> </filter-mapping>
3. Create a new hello.jsp file under Webcontext because the result of the action configured in the struts.xml above is/hello.jsp. If hello.jsp is placed under Web-inf, result should be/web-inf/hello.jsp.
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public " -//apache software foundation//dtd Struts Configuration 2.5//en " http://struts.apache.org/dtds/struts-2.5.dtd" ><struts> <packageextends= "Struts-default" > <default- Action-ref name= "Hello"/> <action name= "Hello" > <result>/WEB-INF/hello.jsp</result> </action> </Package ></struts>
Four, the operation
In the body of the hello.jsp file, enter a line
Here to thank the next my classmate is my college roommate Zhang Mong, so late also help solve the problem.
Eclipse Configuration struts2.x