SSH instance (5), ssh instance

Source: Internet
Author: User

SSH instance (5), ssh instance

Create a struts. xml file in src:

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><constant name="struts.objectFactory" value="spring" /><constant name="struts.enable.DynamicMethodInvocation" value="true" />    <constant name="struts.devMode" value="true" />    <constant name="struts.i18n.reload" value="true" />    <constant name="struts.configuration.xml.reload" value="true" />    <constant name="struts.custom.i18n.resources" value="globalMessages" />    <constant name="struts.url.includeParams" value="none" />    <constant name="struts.ui.theme" value="xhtml"></constant>    <package name="struts2" extends="struts-default">        <default-action-ref name="clasquery"></default-action-ref>        <action name="clasquery" class="clasQueryAction">            <result name="success">/query.jsp</result>            </action>            <action name="clas" class="clasAction">            <result name="success" type="redirect">/clasquery.action</result>            </action>        </package></struts> 

ClasAction. java file:

package com.school.action;import com.school.entity.Clas;import com.school.service.ClasService;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("serial")public class ClasAction extends ActionSupport {        private ClasService clasService;    public void setClasService(ClasService clasService) {        this.clasService = clasService;    }        private Clas clas;    public String execute(){        Clas c=new Clas();        c.setName(clas.getName());        c.setComment(clas.getComment());        clasService.saveClas(c);        return SUCCESS;    }        public Clas getClas() {        return clas;    }        public void setClas(Clas Clas) {        this.clas = Clas;    }}

ClasQueryAction. java file:

Package com. school. action; import java. util. list; import org. apache. struts2.ServletActionContext; import com. opensymphony. xwork2.ActionSupport; import com. school. entity. clas; import com. school. service. clasService; @ SuppressWarnings ("serial") public class ClasQueryAction extends ActionSupport {private ClasService clasService; // set the business logic component public void setClasService (ClasService clasService) {this. clasService = clasService;} public String execute () {List <Clas> claslist = clasService. findAll (); // store all courses in the requested range of ServletActionContext. getRequest (). setAttribute ("claslist", claslist); return SUCCESS ;}}

 

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.