帮朋友搭建个简单的helloworld的平台,较简单,但是能用了。


给ssh的“零配置”一个正解。看我这个就够了ok了!


jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/sshfw?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=round
jdbc.username=root
jdbc.password=leizm


log4j.rootLogger=debug, stdout
log4j.logger.java.sql.Connection=info, stdout
log4j.logger.java.sql.Statement=debug, stdout
log4j.logger.java.sql.PreparedStatement=debug, stdout
log4j.logger.org.hibernate=error
log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.tool.hbm2ddl=debug
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss} %c:%L - %m%n
log4j.category.org.springframework = ON




    
    
    
    
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
        
        
            
                org.hibernate.dialect.MySQL5InnoDBDialect
                thread
                true
                true
                update
            
        
        
    
    
        
    
    
        
            
            
            
            
            
            
            
            
        
    
    
        
        
    





    
    
    
    
    
    
    
        
            /index.jsp
            /error.jsp
        
    




    
        login.html
    
    
        encodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        
    
    
        encodingFilter
        /*
    
    
        struts2
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    
    
        struts2
        /*
    
    
        log4jConfigLocation
        classpath:log4j.properties
    
    
        org.springframework.web.util.Log4jConfigListener
    
    
        contextConfigLocation
        classpath:spring-config.xml
    
    
        org.springframework.web.context.ContextLoaderListener
    
    
        org.springframework.web.context.request.RequestContextListener
    
    
        org.springframework.web.util.IntrospectorCleanupListener
    


package com.lavasoft.demo.web.action;
import com.lavasoft.demo.entity.User;
import com.lavasoft.demo.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
 * Created by Administrator on 14-4-23.
 *
 * @author leizhimin 14-4-23 下午3:09
 */
@Namespace("/demo")
@Component
@Scope("prototype")
public class UserAction extends ActionSupport {
    @Resource
    private UserService userService;
    private User user;
    private List userList;
    @Action(value = "regUser", results = {
            @Result(name = "success", location = "/WEB-INF/pages/login.jsp"),
            @Result(name = "input", location = "/WEB-INF/pages/error.jsp")})
    public String reg() {
        System.out.println("----reg page----");
        return SUCCESS;
    }
    @Action(value = "saveUser", results = {
            @Result(name = "success", location = "/WEB-INF/pages/list.jsp"),
            @Result(name = "input", location = "/WEB-INF/pages/error.jsp")})
    public String save() {
        System.out.println("----save----");
        System.out.println(user);
        userService.saveUser(user);
        return SUCCESS;
    }
    public String list() {
        System.out.println("----list----");
        System.out.println(user);
        userList = userService.queryUserAll();
        return SUCCESS;
    }
    public List getUserList() {
        return userList;
    }
    public void setUserList(List userList) {
        this.userList = userList;
    }
    public UserService getUserService() {
        return userService;
    }
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }
}


package com.lavasoft.demo.dao;
import com.lavasoft.sshfw.core.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
 * Created by Administrator on 14-4-23.
 *
 * @author leizhimin 14-4-23 下午6:43
 */
@Repository
public class UserDAO extends BaseDaoImpl {
}


package com.lavasoft.demo.entity;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
@Entity
@Table(name = "t_demo")
public class User implements java.io.Serializable {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;
    @Column(name = "username", length = 32)
    private String username;
    @Column(name = "password", length = 16)
    private String password;
    public User() {
    }
    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}



package com.lavasoft.demo.service;
import com.lavasoft.demo.dao.UserDAO;
import com.lavasoft.demo.entity.User;
import com.lavasoft.sshfw.core.BaseDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
 * Created by Administrator on 14-4-23.
 *
 * @author leizhimin 14-4-23 下午6:46
 */
@Service
public class UserService {
    @Resource
    private UserDAO userDAO;
    public void saveUser(User user) {
        userDAO.save(user);
    }
    public List queryUserAll() {
        return userDAO.findAll("from User", User.class);
    }
}


<%--
  Created by IntelliJ IDEA.
  User: leizhimin 14-4-23 下午5:51
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    



用户名:
密码:


CREATE TABLE `t_demo` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) DEFAULT NULL,
  `password` varchar(16) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8




webcontent部署为:sshfw

访问地址:


http://localhost:8080/sshfw/demo/regUser


http://localhost:8080/sshfw/demo/saveUser?user.username=wer&user.password=666666666