zoukankan      html  css  js  c++  java
  • SSH(三)创建包和第一个页面

    在ssh web项目src下一次创建

    com.ssh/

      .action

      .dao

      .entity

      .service

    四个包,example:

    在entity包下创建class,name: product →finish

    package com.ssh.entity;
    /**
     * @author:图图
     * @date : 2017-6-12 下午08:54:54
     * 商品属性
     */ 
    public class product {
    	private Integer pid;
    	private String pname;
    	private Double price;
    	public Integer getPid() {
    		return pid;
    	}
    	public void setPid(Integer pid) {
    		this.pid = pid;
    	}
    	public String getPname() {
    		return pname;
    	}
    	public void setPname(String pname) {
    		this.pname = pname;
    	}
    	public Double getPrice() {
    		return price;
    	}
    	public void setPrice(Double price) {
    		this.price = price;
    	}
    	
    }

    在webroot下create我们的第一个页面addproduct.jsp

    注意:Struts2标签库的引入

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <!-- struts2 标签库 -->
    <%@taglib uri ="/struts-tags" prefix="s" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'addproduct.jsp' starting page</title>
        
    	<meta http-equiv="pragma" content="no-cache">
    	<meta http-equiv="cache-control" content="no-cache">
    	<meta http-equiv="expires" content="0">    
    	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    	<meta http-equiv="description" content="This is my page">
    	<!--
    	<link rel="stylesheet" type="text/css" href="styles.css">
    	-->
    
      </head>
      
      <body>
        <h1>商品保存</h1>
        <!-- theme="simple" 放弃使用struts form 样式  -->
        <s:form action="" method="post" namespace="/" theme="simple">
        	<table border="1" width="400">
        		<tr>
        			<td>商品名称:</td>
        			<td><s:textfield name="pname"/></td>
        		</tr>
        		<tr>
        			<td>商品价格:</td>
        			<td><s:textfield name="price"/></td>
        		</tr>
        		<tr>
        			<!-- colspan: 合并单元格-->
        			<td align="center" colspan="2"><input type="submit" value="添加"> </td>
        		</tr>
        	</table>
        </s:form>
      </body>
    </html>
    

    tomcat添加项目ssh

    根据自己的tomcat端口访问:

    http://localhost:8080/ssh/addproduct.jsp

    页面show:

     

  • 相关阅读:
    RN8209校正软件开发心得(1)
    Chrome 31版本导出Excel问题
    ComBox选择
    网页设计的一般步骤
    .NET一套开发工具
    关于用sql语句实现一串数字位数不足在左侧补0的技巧
    python jieba模块详解
    python内置函数详细描述与实例演示
    Markdown的基本语法记录
    python configparser模块详解
  • 原文地址:https://www.cnblogs.com/ckxlovejava/p/6995651.html
Copyright © 2011-2022 走看看