解析Excel和XML解析Excel:result typejson//actionString jsonString JSONObject.fromObject(map
解析Excel和XML
解析Excel:
<result type="json"/>
</action>
String jsonString = JSONObject.fromObject(map).toString();
String jsonString = JSONArray.fromObject(list).toString();
HttpServletResponse response = getResponse();
response.setContentType("text/html;charset=utf-8");
response.getWriter().print(jsonString); dataType: 'json',//返回值类型 一般设置为json
success: function (data, status) {
},
error: function (data, status, e) {//服务器响应失败处理函数
}
});
文件下载
FileInputStream fis=new FileInputStream(file);
https
this.getResponse().setHeader("Pragma", "public");
this.getResponse().setHeader("Cache-Control", "max-age=30");
this.getResponse().setContentType("application/force-download");
this.getResponse().setHeader("content-length", String.valueOf(file.length()));
this.getResponse().setHeader("Content-disposition", "attachment;filename="+ new String(fileName.getBytes("gb2312"),"iso8859-1"));
ServletOutputStream os = this.getResponse().getOutputStream();
int length=0;
while((length=fis.read())!=-1){
os.write(length);
}重启tomcat然后在浏览器中访问"http://服务器IP:8080/"可直接访问到我们上传的项目
以上两种项目发布方式,第一种访问需要加项目名字,第二种不需要加
4.把访问方式设置成https
1.生成证书:
如果 java的环境变量配置完成之后,keytool命令便可以使用,该命令位于"JAVA_HOME/bin"下,生成证书需要如下步骤
执行"keytool -genkey -alias tomcat -keyalg RSA -keypass changeit -storepass changeit -keystore /usr/server.keystore -validity 3600"
用户名输入域名,如128.18.191.143(建议时服务器的IP,不然证书会无效),其它可以全部以 enter 跳过也可以输入相关的信息,最后确认,此时会在/usr下生成server.keystore 文件。
注:参数 -keypass和-storepass来指定该证书的密码
参数 -keystore指定该证书的生成路径
参数 -validity 指证书的有效期(天),缺省有效期只有90天,这里用3600天。
根据server.keystore生成客户端安装的证书,执行"keytool -export -trustcacerts -alias tomcat -file server.cer -keystore server.keystore -storepass changeit"
注:参数 -file来指定该安装证书的生成路径
参数 -keystore指定server.keystore文件所在的路径
参数 -storepass指定生成server.keystore文件证书的密码
命令执行完毕之后会生成一个server.cer的客户端安装文件,可供用户下载安装,具体安装和说明
2.配置tomcat
证书生成完毕之后,开始配置tomcat,编辑"tomcat目录/conf/server.xml",找到
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
在这句话下边加上:
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" minSpareThreads="5" maxSpareThreads="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/usr/server.keystore"
keystorePass="changeit"/> <key column="customerLibId"></key>
<many-to-many table="v5r1_customerlib_app" lazy="true">
<key column="appId"></key>
<many-to-many column="customerLibId"></many-to-many>
</set>
一对多
<set name="ruleReviewStateSet" inverse="true" lazy="true">
<key>
<column name="appId" sql-type="int(1)"></column>
</key>
<one-to-many />
</set>
<many-to-one name="appInfo">
<column name="appId" sql-type="int(1)">
</column>
</many-to-one>
一对一
<many-to-one name="person" column="PERSON_ID" unique="true"/>
<one-to-one name"employee" type="java.lang.Integer">
<column name="ruleId" sql-type="int(1)">
</column>
</key-property>
<key-many-to-one name="appInfo">
<column name="appId" sql-type="int(1)">
</column>
</key-many-to-one>
</composite-id>
<composite-id>
<key-property name="appId" type="java.lang.Integer">
<column name="appId" sql-type="int(1)">
</column>
</key-property>
<key-property name="appName" type="java.lang.String">
<column name="appName" sql-type="varchar(32)">
</column>
</key-property>
</composite-id><property name="jobDataAsMap">
<map>
<entry key="menuService">
<ref bean="menuService"/>
</entry>
</map>
</property>
</bean>
<!--
CronTriggerBean指定工作的准确运行时间
-->
<bean id="cronReportTrigger"
ref="reportJob" />
<property name="cronExpression">
<!-- 设置每天晚上11点的时候,会自动进行版本的定制化 -->
<value>0 0 23 ? * *</value>
</property>
</bean>
<bean />
</list>
</property>
</bean>
if(jobId != null && !"".equals(jobId)) {
query.append(" and id.jobId like ? escape '#' ");
condition.add("%" + jobId.replace("%", "#%").replace("_", "#_") + "%");
}
//构造stepId的条件
if(stepId != null && stepId != -1) {
query.append(" and id.jobStepId=? ");
condition.add(stepId);
}
if(statusId != null &&statusId != -1) {
query.append(" and id.jobStatusId=? ");
condition.add(statusId);
}
if(createStartTime != null && !"".equals(createStartTime)) {
query.append(" and jobCreatTime>=? ");
condition.add(createStartTime.replace("-", "_") + " 00:00:00");
}
if(createEndTime != null && !"".equals(createEndTime)) {
query.append(" and jobCreatTime<=? ");
condition.add(createEndTime.replace("-", "_") + "23:59:59");
}
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException,
SQLException {
String hql = "from JobDispatch where " + query.toString() + "order by jobCreatTime desc";
Query query = session.createQuery(hql);
//为query赋参数
for(int i=0; i<condition.size(); i++) {
Object obj = condition.get(i);
if(obj instanceof Integer) {
query.setInteger(i, (Integer)obj);
} else if(obj instanceof String) {
query.setString(i, (String)obj);
}
}
return query.setFirstResult(startRow).setMaxResults(size).list();
}
});
}