struts2里面的<s:property>不显示值
jsp页面的我只黏贴了一部分,Temporary也只黏贴一部分,希望大手子帮帮忙,谢谢
我想要问的问题就是,其他的地方都显示数据,唯独职位属性,和空闲时间是不显示的,还有就是想请教一下,我想显示的图片应该怎么写,并且我的tomcat不报错
jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ 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 'ShowSel.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">
-->
<style type="text/css">
#submit {
padding-left: 380px;
}
</style>
</head>
<body bgcolor="#3399FF">
<form action="">
<s:if test="temporary!=null&&temporary.T_Name!=''&&temporary.T_Telephone!=''">
<table border="2" bordercolor=" " width="1000px" cellpadding="3">
<tr height="50px;">
<td align="right" width="100px;" align="right">
姓名:
</td>
<td width="250px;">
<s:property value="temporary.T_Name"/>
</td>
<td align="right" width="170px;">
主要工作岗位:
</td>
<td width="260px;">
<s:property value="temporary.T_Major_Jobs"/>
</td>
<td colspan="2" rowspan="6" width="30px;">
<img src="<s:property value="temporary.T_Photo"/>" />
</td>
</tr>
<tr height="50px;">
<td align="right">
性别:
</td>
<td>
<s:property value="temporary.T_Sex"/>
</td>
<td align="right">
职位属性:
</td>
<td>
<s:property value="temporary.T_P_Property"/>
</td>
</tr>
<tr height="50px;">
<td align="right">
个人状态;
</td>
<td>
<s:property value="temporary.T_Status"/>
</td>
<td align="right">
每周空闲时间:
</td>
<td>
<s:property value="temporary.T_F_Time"/>
</td>
<td>
</td>
</tr>
</table>
</s:if>
<br>
<div id="submit">
<input type="button" id="up_T" value="修改"
style="width: 100px; height: 30px;">
<input type="button" id="up_T" value="删除"
style="width: 100px; height: 30px;">
</div>
</form>
</body>
</html>
Temporary代码
package com.sn.bean;
import java.sql.Date;
public class Temporary {
public String getT_P_Property() {
return T_P_Property;
}
public void setT_P_Property(String T_P_Property) {
this.T_P_Property = T_P_Property;
}
public void setT_F_time(String T_F_Time) {
this.T_F_time = T_F_Time;
}
public String getT_Name() {
return T_Name;
}
public Temporary(Date T_E_Time, String T_P_Property, String T_Respective_Spheres,
String T_Major_Jobs, String T_Id,String T_Level ,String T_F_Time, String T_Name,
String T_Telephone, String T_Id_Card, String T_Bank_Card, String T_Photo,
String T_Bank, String T_Sex, String T_Household_Register,
String T_Status, String T_N_C_P_Name, String T_N_C_P_Id, String T_Gread,
String T_Address, String T_Major, String T_Driver_License,
String T_Computer_Operating, String T_Camear, String T_Outflow,
String T_Black_List) {
super();
this.T_E_Time = T_E_Time;
this.T_P_Property = getT_P_Property();
this.T_Respective_Spheres = T_Respective_Spheres;
this.T_Major_Jobs = T_Major;
this.T_Id = T_Id;
this.T_Level=T_Level;
this.T_F_time = T_F_Time;
this.T_Name = T_Name;
this.T_Telephone = T_Telephone;
this.T_Id_Card = T_Id_Card;
this.T_Bank_Card = T_Bank_Card;
this.T_Photo = T_Photo;
this.T_Bank = T_Bank;
this.T_Sex = T_Sex;
this.T_Household_Register = T_Household_Register;
this.T_Status = T_Status;
this.T_N_C_P_Name = T_N_C_P_Name;
this.T_N_C_P_Id = T_N_C_P_Id;
this.T_Gread = T_Gread;
this.T_Address = T_Address;
this.T_Major = T_Major;
this.T_Driver_License = T_Driver_License;
this.T_Computer_Operating = T_Computer_Operating;
this.T_Camear = T_Camear;
this.T_Outflow = T_Outflow;
this.T_Black_List = T_Black_List;
}
public Temporary() {
super();
// TODO Auto-generated constructor stub
}
private Date T_E_Time;//入职时间(T_E_Time)
private String T_P_Property;//职位属性(T_P_Property)
private String T_Respective_Spheres;//所属圈层(T_Respective_spheres)
private String T_Major_Jobs;//主要工作岗位(T_Major_Jobs)
private String T_Id;//编号(T_Id)
private String T_Level;//级别(T_Level)
private String T_F_time;//每周空闲时间(T_F_time)
private String T_Name;//姓名(T_Name)
private String T_Telephone;//电话(T_Telephone)
private String T_Id_Card;//照片(T_Photo)
private String T_Bank_Card;//身份证号码(T_Id_Card)
private String T_Photo;//银行卡号(T_Bank_Card)
private String T_Bank;//所属银行(T_Bank)
private String T_Sex;//性别(T_Sex)
private String T_Household_Register;//户籍(T_Household_Register)
private String T_Status;//个人状态(T_Status)
private String T_N_C_P_Name;//当前所执行项目名称(T_N_C_P_Name)
private String T_N_C_P_Id;//当前所执行项目编号(T_N_C_P_Id)
private String T_Gread;//就读年级(T_Gread)
private String T_Address;//校区/住址(T_Address)
private String T_Major;//专业(T_Major)
private String T_Driver_License;//驾照(T_Driver_License)
private String T_Computer_Operating;//电脑操作(T_Computer_Operating)
private String T_Camear;//相机(T_Camear)
private String T_Outflow;//流失(T_Outflow)
private String T_Black_List;//黑名单(T_Black_List)
}
TemporaryAction代码
package com.sn.action;
import com.opensymphony.xwork2.ActionSupport;
import com.sn.bean.Temporary;
import com.sn.dao.TemporaryDao;
public class TemporaryAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private Temporary temporary;
private String selTem_1_msg;
private String selTem_0_msg;
public Temporary getTemporary() {
return temporary;
}
public void setTemporary(Temporary temporary) {
this.temporary = temporary;
}
public String getSelTem_1_msg() {
return selTem_1_msg;
}
public void setSelTem_1_msg(String selTem_1Msg) {
selTem_1_msg = selTem_1Msg;
}
public String getSelTem_0_msg() {
return selTem_0_msg;
}
public void setSelTem_0_msg(String selTem_0Msg) {
selTem_0_msg = selTem_0Msg;
}
public String selTem() {
String cnt;
String T_Name=temporary.getT_Name();
String T_Telephone=temporary.getT_Telephone();
TemporaryDao td = new TemporaryDao();
temporary = td.selTem(T_Name, T_Telephone);
if (temporary!=null) {
cnt="selTem_1";
}else {
cnt="selTem_0";
selTem_0_msg="没有此用户,请确认您所输入的姓名和电话后查询,谢谢~!";
}
return cnt;
}
}
struts
[解决办法]
你的写法没有问题!
值没有显示、你调试看看后台查询出来的时候是否有值了!
如果数据库中这个字段没有值、后台也查询不出来、前台当然也只能显示空的。
private String T_Id_Card; //照片(T_Photo)
private String T_Bank_Card; //身份证号码(T_Id_Card)
private String T_Photo; //银行卡号(T_Bank_Card)
你的图片这么显示:
假设你的T_Photo字段存储的是图片的名称:imagesName.jsp
你图片的存储路径为:WebRoot目录的images文件夹下
写绝对路径:/工程名称/images/imagesName.jsp
<img src="<%=path%>/images/<s:property value="temporary.T_Photo"/>" />