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;
}
}