Struts2概述

1 struts2框架应用javaee三层结构中web层框架

2 struts2框架在Struts1webwork基础之上发展全新的框架

3struts2 能解决的问题

struts2能解决的问题_看图王.jpg

Struts2

第一步 导入jar

 1)在lib中有jar 不能把这些jar都导入到项目中

  2)到apps目录里面,找到实例程序,

image.png

第二步创建Action

package com.netxintai.action;

public class UserAction {
	
	/**
	 * 访问Action,每次访问action时候,默认的访问方法是execute方法
	 * 
	 */
	
	public String execute(){
		
		System.out.println("当你看到这条信息,说明你配置的最简单的struts2已经成功");
	
		return "ok";
	}

}

第三步 配置Action路径

1,创建一个Struts2核心配置文件,核心配置文件名称和位置是固定的

位置必须在src下面struts.xml;

2,引入dtd约束

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
	
	
	<package name="default" namespace="/" extends="struts-default">
	
	<action name="useraction" class="com.netxintai.action.UserAction">
	
	<result name="ok">/index.jsp</result>
	
	</action>
	
	
	</package>
</struts>

4 配置struts2过滤器

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>struts2day01</display-name>
   <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>
  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

至此就可以运行项目直接在地址栏输入路径http://localhost:8080/struts2day01/useraction如果出现如下代码说明你已经配置好了struts2开发环境

image.png

image.png

117 Thoughts on “struts2入门案列(一)

  1. Hello there, just became aware of your blog through Google, and found that it is really informative.
    I’m gonna watch out for brussels. I will be grateful if you continue this
    in future. A lot of people will be benefited from your writing.
    Cheers! Najlepsze escape roomy

  2. Very interesting topic, thank you for putting up.!

  3. There’s certainly a great deal to know about this topic. I love all the points you have made.

  4. This is a topic that is near to my heart… Thank you! Exactly where can I find the contact details for questions?

  5. Your style is very unique in comparison to other people I’ve read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.

  6. May I simply say what a comfort to uncover someone who actually understands what they’re discussing on the internet. You actually realize how to bring an issue to light and make it important. A lot more people really need to check this out and understand this side of the story. I was surprised that you are not more popular given that you surely have the gift.

  7. Great post! We are linking to this great post on our website. Keep up the good writing.

  8. Right here is the perfect website for everyone who really wants to find out about this topic. You realize so much its almost tough to argue with you (not that I really will need to…HaHa). You definitely put a new spin on a topic which has been written about for years. Excellent stuff, just great.

  9. Good information. Lucky me I came across your site by accident (stumbleupon). I have bookmarked it for later!

  10. Excellent post. I will be facing many of these issues as well..

  11. An outstanding share! I’ve just forwarded this onto a colleague who had been conducting a little homework on this. And he actually ordered me dinner due to the fact that I found it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this topic here on your web page.

  12. This website really has all of the info I wanted concerning this subject and didn’t know who to ask.

  13. I have to thank you for the efforts you’ve put in writing this site. I am hoping to see the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has encouraged me to get my own, personal blog now 😉

  14. After checking out a number of the blog posts on your blog, I honestly appreciate your way of blogging. I added it to my bookmark site list and will be checking back in the near future. Please visit my web site too and tell me how you feel.

  15. Aw, this was a very nice post. Finding the time and actual effort to produce a top notch article… but what can I say… I procrastinate a whole lot and don’t seem to get anything done.

  16. Your style is so unique in comparison to other folks I’ve read stuff from. Thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this site.

  17. Good post. I am facing many of these issues as well..

  18. You are so cool! I do not believe I have read anything like that before. So wonderful to discover somebody with genuine thoughts on this subject matter. Really.. thanks for starting this up. This website is one thing that is needed on the web, someone with some originality.

  19. Right here is the perfect site for everyone who would like to find out about this topic. You realize so much its almost tough to argue with you (not that I personally would want to…HaHa). You definitely put a brand new spin on a subject that has been discussed for decades. Wonderful stuff, just excellent.

  20. Very nice post. I certainly love this website. Continue the good work!

  21. It’s hard to find well-informed people for this subject, however, you seem like you know what you’re talking about! Thanks

  22. Good day! I just wish to offer you a huge thumbs up for your great info you have got right here on this post. I’ll be returning to your site for more soon.

  23. Having read this I believed it was very informative. I appreciate you spending some time and energy to put this information together. I once again find myself personally spending way too much time both reading and leaving comments. But so what, it was still worth it!

  24. An interesting discussion is definitely worth comment. I believe that you ought to publish more on this issue, it may not be a taboo subject but usually folks don’t talk about these topics. To the next! Cheers!

  25. Next time I read a blog, Hopefully it won’t disappoint me just as much as this particular one. I mean, Yes, it was my choice to read, but I really thought you would have something useful to say. All I hear is a bunch of whining about something you could fix if you weren’t too busy looking for attention.

  26. Oh my goodness! Impressive article dude! Thanks, However I am encountering problems with your RSS. I don’t understand the reason why I am unable to join it. Is there anybody getting similar RSS problems? Anyone that knows the solution can you kindly respond? Thanks!

  27. Aw, this was an extremely good post. Taking a few minutes and actual effort to make a really good article… but what can I say… I procrastinate a lot and don’t manage to get anything done.

  28. Greetings! Very useful advice within this post! It is the little changes that will make the greatest changes. Many thanks for sharing!

  29. Having read this I thought it was extremely informative. I appreciate you taking the time and effort to put this informative article together. I once again find myself spending a lot of time both reading and leaving comments. But so what, it was still worthwhile.

  30. An impressive share! I’ve just forwarded this onto a co-worker who has been doing a little research on this. And he in fact ordered me lunch due to the fact that I discovered it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending time to talk about this topic here on your internet site.

  31. Pretty! This was a really wonderful article. Thank you for providing these details.

  32. This site definitely has all the info I wanted about this subject and didn’t know who to ask.

  33. I could not resist commenting. Very well written.

  34. You ought to take part in a contest for one of the most useful sites on the net. I will recommend this website!

  35. Hello there! I could have sworn I’ve visited this site before but after browsing through a few of the posts I realized it’s new to me. Anyhow, I’m definitely pleased I stumbled upon it and I’ll be book-marking it and checking back frequently!

  36. Everything is very open with a clear clarification of the issues. It was really informative. Your site is very helpful. Thank you for sharing!

  37. You should be a part of a contest for one of the most useful sites on the internet. I most certainly will highly recommend this site!

  38. I’m amazed, I have to admit. Rarely do I come across a blog that’s equally educative and engaging, and without a doubt, you’ve hit the nail on the head. The issue is something which too few men and women are speaking intelligently about. Now i’m very happy I stumbled across this during my search for something regarding this.

  39. It’s nearly impossible to find experienced people in this particular subject, but you seem like you know what you’re talking about! Thanks

  40. This is the perfect web site for anybody who would like to understand this topic. You know a whole lot its almost tough to argue with you (not that I really will need to…HaHa). You definitely put a fresh spin on a topic that has been discussed for years. Excellent stuff, just great.

  41. Very good information. Lucky me I ran across your site by chance (stumbleupon). I have saved as a favorite for later!

  42. An impressive share! I have just forwarded this onto a friend who has been doing a little research on this. And he in fact ordered me breakfast due to the fact that I stumbled upon it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanx for spending the time to talk about this matter here on your website.

  43. It’s hard to find experienced people in this particular topic, but you seem like you know what you’re talking about! Thanks

  44. Howdy, I think your website could possibly be having internet browser compatibility problems. Whenever I look at your website in Safari, it looks fine however when opening in Internet Explorer, it has some overlapping issues. I simply wanted to provide you with a quick heads up! Other than that, wonderful site!

  45. I love reading a post that can make men and women think. Also, thanks for permitting me to comment.

  46. Good web site you have here.. It’s difficult to find quality writing like yours nowadays. I seriously appreciate individuals like you! Take care!!

  47. I truly love your blog.. Great colors & theme. Did you make this web site yourself? Please reply back as I’m planning to create my own personal site and want to learn where you got this from or exactly what the theme is called. Kudos.

  48. Excellent post. I certainly appreciate this website. Keep writing!

  49. Aw, this was an incredibly nice post. Taking a few minutes and actual effort to create a top notch article… but what can I say… I procrastinate a lot and never seem to get anything done.

  50. Good post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It’s always helpful to read articles from other authors and practice something from other sites.

  51. After I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on every time a comment is added I recieve four emails with the exact same comment. Is there a way you can remove me from that service? Thanks.

  52. I like it whenever people get together and share opinions. Great site, keep it up.

  53. I need to to thank you for this excellent read!! I certainly enjoyed every bit of it. I’ve got you book marked to check out new stuff you post…

  54. A fascinating discussion is worth comment. I believe that you need to publish more about this subject matter, it might not be a taboo matter but usually people do not discuss these subjects. To the next! All the best!

  55. An interesting discussion is worth comment. I believe that you ought to write more on this subject matter, it might not be a taboo matter but usually people do not speak about these topics. To the next! Kind regards!

  56. Greetings! Very useful advice in this particular article! It is the little changes that will make the most important changes. Thanks a lot for sharing!

  57. This is the perfect blog for everyone who wishes to understand this topic. You understand so much its almost tough to argue with you (not that I really would want to…HaHa). You certainly put a brand new spin on a topic that’s been written about for decades. Excellent stuff, just great.

  58. Oh my goodness! Incredible article dude! Many thanks, However I am having troubles with your RSS. I don’t know the reason why I can’t subscribe to it. Is there anybody else having identical RSS issues? Anyone that knows the answer can you kindly respond? Thanx!

  59. Very good post! We are linking to this great post on our site. Keep up the great writing.

  60. Hello! I could have sworn I’ve visited this site before but after browsing through some of the posts I realized it’s new to me. Regardless, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back regularly!

  61. Good info. Lucky me I recently found your blog by chance (stumbleupon). I have book marked it for later!

  62. An outstanding share! I’ve just forwarded this onto a co-worker who had been doing a little homework on this. And he actually ordered me dinner due to the fact that I found it for him… lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending some time to discuss this topic here on your internet site.

  63. Saved as a favorite, I really like your site.

  64. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  65. Good article! We are linking to this particularly great article on our website. Keep up the good writing.

  66. Hello there! Do you know if they make any plugins to help with SEO?
    I’m trying to get my website to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Many thanks! I saw
    similar text here: Eco product

  67. This is the perfect webpage for anyone who wishes to find out about this topic. You know so much its almost hard to argue with you (not that I personally would want to…HaHa). You certainly put a brand new spin on a subject that’s been written about for many years. Wonderful stuff, just wonderful.

  68. You need to take part in a contest for one of the greatest websites on the net. I am going to highly recommend this website!

  69. This is the right site for anyone who hopes to find out about this topic. You understand a whole lot its almost hard to argue with you (not that I actually would want to…HaHa). You definitely put a fresh spin on a subject that’s been written about for many years. Great stuff, just wonderful.

  70. It’s hard to come by knowledgeable people on this topic, but you seem like you know what you’re talking about! Thanks

  71. Greetings! Very useful advice within this post! It is the little changes which will make the largest changes. Thanks for sharing!

  72. Your style is really unique compared to other people I’ve read stuff from. Many thanks for posting when you have the opportunity, Guess I’ll just book mark this site.

  73. Very good article. I’m going through many of these issues as well..

  74. Hi, I do believe this is a great site. I stumbledupon it 😉 I am going to revisit yet again since I book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to help others.

  75. May I just say what a comfort to uncover somebody who really understands what they’re discussing over the internet. You definitely realize how to bring an issue to light and make it important. More people really need to look at this and understand this side of the story. I was surprised you aren’t more popular since you surely have the gift.

  76. I was pretty pleased to uncover this great site. I want to to thank you for your time for this particularly wonderful read!! I definitely appreciated every bit of it and i also have you saved as a favorite to see new stuff in your blog.

  77. This website truly has all the information and facts I wanted concerning this subject and didn’t know who to ask.

  78. Great info. Lucky me I found your site by chance (stumbleupon). I’ve saved as a favorite for later!

  79. Aw, this was an exceptionally nice post. Taking the time and actual effort to produce a superb article… but what can I say… I hesitate a lot and never manage to get nearly anything done.

  80. Howdy! I could have sworn I’ve visited this site before but after browsing through some of the articles I realized it’s new to me. Anyhow, I’m definitely pleased I stumbled upon it and I’ll be bookmarking it and checking back often!

  81. The next time I read a blog, I hope that it does not fail me just as much as this particular one. I mean, Yes, it was my choice to read, but I truly thought you would probably have something helpful to say. All I hear is a bunch of crying about something that you could fix if you were not too busy looking for attention.

  82. After I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive four emails with the same comment. Perhaps there is an easy method you are able to remove me from that service? Many thanks.

  83. Very nice write-up. I absolutely love this site. Keep it up!

  84. Several Caribbean’s ships are most innovative and exciting in the Galveston travel trade.

  85. Can I simply just say what a comfort to uncover somebody who actually understands what they are talking about over the internet. You certainly know how to bring a problem to light and make it important. More and more people ought to check this out and understand this side of the story. I was surprised you’re not more popular since you most certainly possess the gift.

  86. A motivating discussion is worth comment. I do think that you ought to write more about this subject, it may not be a taboo matter but usually people do not talk about these topics. To the next! Best wishes!

  87. This is the right site for anybody who hopes to understand this topic. You know a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You certainly put a new spin on a subject that has been discussed for many years. Great stuff, just excellent.

  88. Howdy! This blog post couldn’t be written any better! Looking through this article reminds me of my previous roommate! He always kept talking about this. I’ll send this post to him. Fairly certain he’ll have a very good read. Thank you for sharing!

  89. Excellent article. I will be dealing with many of these issues as well..

  90. Next time I read a blog, I hope that it won’t fail me just as much as this particular one. After all, Yes, it was my choice to read, however I actually thought you’d have something useful to talk about. All I hear is a bunch of complaining about something that you could fix if you weren’t too busy looking for attention.

  91. Quay lén trong phòng wc

  92. Spot on with this write-up, I honestly feel this website needs a great deal more attention. I’ll probably be back again to see more, thanks for the advice.

  93. Hi, I do think this is an excellent website. I stumbledupon it 😉 I will come back yet again since i have saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to help others.

  94. The very next time I read a blog, Hopefully it won’t fail me just as much as this particular one. I mean, Yes, it was my choice to read, however I really thought you’d have something interesting to say. All I hear is a bunch of crying about something that you can fix if you were not too busy searching for attention.

  95. Spot on with this write-up, I absolutely feel this site needs a great deal more attention. I’ll probably be returning to see more, thanks for the info.

  96. This is a great tip especially to those fresh to the blogosphere. Short but very precise info… Many thanks for sharing this one. A must read post!

  97. I wanted to thank you for this very good read!! I certainly enjoyed every little bit of it. I have you saved as a favorite to look at new things you post…

  98. I wanted to thank you for this excellent read!! I definitely loved every bit of it. I’ve got you book-marked to check out new things you post…

  99. This website truly has all the information I needed about this subject and didn’t know who to ask.

  100. You need to take part in a contest for one of the best websites on the net. I am going to recommend this site!

  101. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  102. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  103. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  104. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  105. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  106. After checking out a handful of the blog articles on your blog, I seriously like your technique of blogging. I book marked it to my bookmark webpage list and will be checking back soon. Please visit my web site as well and let me know what you think.

  107. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  108. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  109. Your style is so unique compared to other folks I have read stuff from. Thank you for posting when you have the opportunity, Guess I will just bookmark this blog.

  110. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  111. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  112. You should be a part of a contest for one of the highest quality blogs online. I most certainly will highly recommend this website!

  113. Hi there! I could have sworn I’ve visited this blog before but after going through many of the posts I realized it’s new to me. Anyways, I’m certainly happy I discovered it and I’ll be bookmarking it and checking back often!

  114. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  115. It’s nearly impossible to find experienced people for this topic, but you seem like you know what you’re talking about! Thanks

  116. There’s certainly a lot to find out about this issue. I love all the points you’ve made.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Post Navigation