美文网首页
SSH开发个人博客(一)

SSH开发个人博客(一)

作者: 晚上吃火锅吗 | 来源:发表于2017-02-25 14:11 被阅读0次

java jdk1.8
依赖包版本分别用 struts2.3.1,hibernate4.2,spring
先做个首页面,使用bootstrap框架就能很轻松的制作一个页面,命名为myBlog.html。
在eclipse中建立一个web项目,配置web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>ssh_demo</display-name>
  <welcome-file-list>
    <welcome-file>myBlog.html</welcome-file>
  </welcome-file-list>
  
  <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>
</web-app>

建立struts2.xml配置文件

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

<struts>
    <package name="default" extends="struts-default">
    <action name="index" class="action.blogAction">
        <result name="success">/myBlog.html</result>        
    </action>
    </package>
</struts>

blogAction:

public class blogAction extends ActionSupport {
    public String execute() throws Exception {
        return SUCCESS;
    }   
}

启动tomcat,效果如下:



项目工程结构如下:


相关文章

网友评论

      本文标题:SSH开发个人博客(一)

      本文链接:https://www.haomeiwen.com/subject/jxfewttx.html