[JAVA web项目]dynamic web project部署strust2.3.24
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了[JAVA web项目]dynamic web project部署strust2.3.24,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3751字,纯文字阅读大概需要6分钟。
内容图文
![[JAVA web项目]dynamic web project部署strust2.3.24](/upload/InfoBanner/zyjiaocheng/1106/bfb9a19cd71a4df99c275d98e4dadefd.jpg)
first,下载eclipse-j2ee
和 strust2:
http://struts.apache.org/download.cgi
可以考虑下载“Full Distribution”版本
1 解压strust2,挑选需要的文件
2 src根目录下新增文件struts.xml。
这里要注意 struts public是否配置正确
extends是否有配置,可以默认strusts-default
1 <? xml version="1.0" encoding="UTF-8" ?> 2 3 <! DOCTYPE struts PUBLIC 4 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" 5 "http://struts.apache.org/dtds/struts-2.3.dtd" > 6 7 < struts > 8 9 < constant name ="struts.enable.DynamicMethodInvocation" value ="false" /> 10 < constant name ="struts.devMode" value ="true" /> 11 < package name ="default" extends ="struts-default" > 12 13 < default-action-ref name ="index" /> 14 < global-results > 15 < result name ="error" >/error.jsp</result>16</global-results>17<global-exception-mappings>18<exception-mapping exception="java.lang.Exception" result="error"/>19</global-exception-mappings>202122<action name="Login" class="action.LoginAction">23<result>/TestLoginResult.jsp</result>24<result name="input">/TestLogin.jsp</result>25</action>26</package>27
28</struts>
3 配置web.xml
welcome-file尽量配置,不然很容易出现问题。(“There is no Action mapped for namespace...”)
1 <? xml version="1.0" encoding="UTF-8" ?> 2 < web-app version ="2.5" 3 xmlns ="http://java.sun.com/xml/ns/javaee" 4 xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation ="http://java.sun.com/xml/ns/javaee 6 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > 7 8 < display-name >Struts Blank</display-name> 9<filter>10<filter-name>struts2test</filter-name>11<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>12</filter>1314<filter-mapping>15<filter-name>struts2test</filter-name>16<url-pattern>/*</url-pattern>17</filter-mapping>1819<welcome-file-list>20<welcome-file>Test.html</welcome-file>21</welcome-file-list>22</web-app>
4 然后参考以下截图目录
5 新增文件TestLogin.jsp
1 <% @ page language = " java " contentType = " text/html; charset=ISO-8859-1 " 2 pageEncoding = " ISO-8859-1 " %> 3 <! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > 4 < html > 5 < head > 6 < meta http-equiv ="Content-Type" content ="text/html; charset=ISO-8859-1" > 7 < title >Insert title here</title> 8</head> 9<body>10<form action="Login" method="post">11 u:<input type="text" name="user"/>12<p />13 p:<input type="text" name="psw"/>14<p />15<input type="submit" name="sm" value="OK"/>16</form>17</body>18</html>
6 新增 TestLoginResult.jsp
这个只是登录成功后显示的,可以为空。
7 src.action下新增LoginAction.java
在哪个目录下新增,是和struts.xml配置有关
里面的成员变量user,psw是和TestLogin.jsp中的对应的。
1 package action; 2 3 import com.opensymphony.xwork2.ActionSupport; 4 5 public class LoginAction extends ActionSupport 6{ 7 8/** 9 * 10*/11privatestaticfinallong serialVersionUID = 1L; 12public String user; 13public String psw; 1415public String getUser() 16 { 17return user; 18 } 192021publicvoid setUser(String user) 22 { 23this.user = user; 24 } 252627public String getPsw() 28 { 29return psw; 30 } 313233publicvoid setPsw(String psw) 34 { 35this.psw = psw; 36 } 3738 @Override 39public String execute() throws Exception 40 { 41// TODO Auto-generated method stub42if(this.user.equals("a") && this.psw.equals("b")) 43 { 44return SUCCESS; 45 } 46elsereturn INPUT; 47 } 4849 }
然后就可以调试了。
如果你发现还是不成功,查看classes输出文件是否设置正确。
原文:http://www.cnblogs.com/SKeyC27/p/4626357.html
内容总结
以上是互联网集市为您收集整理的[JAVA web项目]dynamic web project部署strust2.3.24全部内容,希望文章能够帮你解决[JAVA web项目]dynamic web project部署strust2.3.24所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。