Using Springside 3.1.4.3 The entire process of developing a Web project (medium)

Source: Internet
Author: User
Tags stub

Step seventh, write action and JSP. In Springside 3.1.4.3, the use of Struts 2 and its convention plug-ins, is not the previous use of the Codebehind Plug-ins, about the Convention plug-in, here to say a few words, the plug-ins most of the functions and Codebehind is the same, the only thing that's confusing is where the plugin is looking for the action class, which is based on the value of the Struts.convention.package.locators attribute, in which the value is "Web", You need to check the Struts.xml file to know. This means that Convention will look for all the packages that contain the word "web" and look for the action class in the package and its child packages. This is why the action layer's package name is Personal.youxia.web.

About the Springside 3 kinds of struts, we can look at a previous article I wrote Springside 3 of the Struts 2

The implementation of Articleaction is as follows, modify the index.jsp to redirect it to Article.action, the action defaults to calling its list method to display all articles and returning article.jsp as its view. On the view, there is a connection to add the article, click the connection to access Article!input.action, then call the Articleaction input method, and return Article-input.jsp as its view, enter the content of the article in the view, click Save, Call Article!save.action, then call the Articleaction Save method to save the data, if you want to delete the article, call Article!delete.action, the Articleaction Delete method is invoked. In the process of calling the above method, the Prepare series method is automatically invoked.

Therefore, this step involves three JSP files and an action class, which are

index.jsp

article.jsp

article-input.jsp

Articleaction.java

Index.jsp's changes are simple, just let the project start to visit the articleaction, rather than the default useraction. The code for INDEX.JSP is as follows:

<% response.sendredirect ("article.action"); %>

At this point, the focus goes into articleaction, creating the action with the following code frame:

package personal.youxia.web;
import personal.youxia.entity.entities.Article;
public class ArticleAction extends  CrudActionSupport<Article> {
     @Override
     public String delete() throws Exception {
         // TODO Auto-generated method stub
         return null;
     }
     @Override
     public String list() throws Exception {
         // TODO Auto-generated method stub
         return null;
     }
     @Override
     protected void prepareModel() throws Exception {
         // TODO Auto-generated method stub
     }
     @Override
     public String save() throws Exception {
         // TODO Auto-generated method stub
         return null;
     }
     public Article getModel() {
         // TODO Auto-generated method stub
         return null;
     }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.