中文字幕亚洲乱码熟女一区二区 ,亚洲一区二区三区成人网站,最新亚洲人成无码网www电影http://www.tkk7.com/hackang/category/8986.html初生牛犢zh-cnThu, 01 Mar 2007 18:26:28 GMTThu, 01 Mar 2007 18:26:28 GMT60利用spring,啟動context時自動執行某方法http://www.tkk7.com/hackang/archive/2006/09/21/71073.html龍卷風驛站龍卷風驛站Thu, 21 Sep 2006 05:38:00 GMThttp://www.tkk7.com/hackang/archive/2006/09/21/71073.htmlhttp://www.tkk7.com/hackang/comments/71073.htmlhttp://www.tkk7.com/hackang/archive/2006/09/21/71073.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/71073.htmlhttp://www.tkk7.com/hackang/services/trackbacks/71073.html首先在spring配置文件中定義bean:

<bean id="initSystemService"
??????? class="com.meetexpo.cms.backend.service.InitSystemServiceImp">
??????? <property name="sysConfigService">
??????????? <ref bean="sysConfigService"/>
??????? </property>
??????? <property name="sysForbidWordsService">
??????????? <ref bean="sysForbidWordsService"/>
??????? </property>
??????? <property name="sysLogDefinePath">
??????????? <value>SysLogDescriptions.xml</value>
??????? </property>??????
??????? <property name="privilegesFrontPath">
??????????? <value>ActionPrivilegesFront.xml</value>
??????? </property>?????????????
??????? <property name="mailSender">
???<ref local="mailSender" />
??</property>
??? </bean>

InitSystemServiceImp.java中部分代碼如下:

import org.springframework.beans.factory.InitializingBean;

public class InitSystemServiceImp implements IInitSystemService,InitializingBean {
???ISysConfigService sysConfigService;
??? ISysForbidWordsService sysForbidWordsService;
????private String sysLogDefinePath;
??? MailSenderTask mailSender;
??? private String privilegesFrontPath;



public void afterPropertiesSet() throws Exception {
????????updateConf();
??????? updateForbidWords();
??????? getSysLogDefine();
????????//set the value to the mail sender
????????updateMailConf();
??????? getPrivilegesFrontDefine();
?}

?

在此要實現afterPropertiesSet接口,afterPropertiesSet()中的方法會隨系統啟動時自動執行,可做一些系統參數初始化使用




或者在action中也可以實現

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.WebApplicationContext;


public class FacadeExporterAction extends BaseAction implements ApplicationContextAware{
}

可以利用set方法賦初值



龍卷風驛站 2006-09-21 13:38 發表評論
]]>
解決FCKeditor上傳文件的中文問題 http://www.tkk7.com/hackang/archive/2006/08/02/61362.html龍卷風驛站龍卷風驛站Wed, 02 Aug 2006 09:12:00 GMThttp://www.tkk7.com/hackang/archive/2006/08/02/61362.htmlhttp://www.tkk7.com/hackang/comments/61362.htmlhttp://www.tkk7.com/hackang/archive/2006/08/02/61362.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/61362.htmlhttp://www.tkk7.com/hackang/services/trackbacks/61362.htmlFCKeditor 上傳文件都是取的你當前的文件名,如果服務器上有同名文件,會自動命名類似xxx(1).xx

英文和數字的文件名還好,但是遇到中文文件名會有一點小麻煩,就是返回上傳后的文件路徑有亂碼。


一不做,二不休,干脆自定義上傳后的文件名規則,就是按當前時間(long型)+隨機數 組成。

這樣可以徹底解決問題。


首先要更改servlet的路徑

web.xml中:
.......................................
?<servlet-name>SimpleUploader</servlet-name>

??????? <servlet-class>com.lion.cms.frontend.servlet.SimpleUploaderServlet</servlet-class>

.......................................

servlet代碼如下:
package com.lion.cms.frontend.servlet;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;


import org.apache.commons.fileupload.*;


import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

/**
?* Servlet to upload files.<br>
?*
?* This servlet accepts just file uploads, eventually with a parameter specifying file type
?*
?* @author Simone Chiaretta (simo@users.sourceforge.net)
?*/

public class SimpleUploaderServlet extends HttpServlet {
???
??? private static String baseDir;
??? private static boolean debug=false;
??? private static boolean enabled=false;
??? private static Hashtable allowedExtensions;
??? private static Hashtable deniedExtensions;
???
??? /**
???? * Initialize the servlet.<br>
???? * Retrieve from the servlet configuration the "baseDir" which is the root of the file repository:<br>
???? * If not specified the value of "/UserFiles/" will be used.<br>
???? * Also it retrieve all allowed and denied extensions to be handled.
???? *
???? */
???? public void init() throws ServletException {
???????
??????? debug=(new Boolean(getInitParameter("debug"))).booleanValue();
???????
??????? if(debug) System.out.println("\r\n---- SimpleUploaderServlet initialization started ----");
???????
??????? baseDir=getInitParameter("baseDir");
??????? enabled=(new Boolean(getInitParameter("enabled"))).booleanValue();
??????? if(baseDir==null)
??????????? baseDir="/UserFiles/";
??????? String realBaseDir=getServletContext().getRealPath(baseDir);
??????? File baseFile=new File(realBaseDir);
??????? if(!baseFile.exists()){
??????????? baseFile.mkdir();
??????? }
???????
??????? allowedExtensions = new Hashtable(3);
??????? deniedExtensions = new Hashtable(3);
???????????????
??????? allowedExtensions.put("File",stringToArrayList(getInitParameter("AllowedExtensionsFile")));
??????? deniedExtensions.put("File",stringToArrayList(getInitParameter("DeniedExtensionsFile")));

??????? allowedExtensions.put("Image",stringToArrayList(getInitParameter("AllowedExtensionsImage")));
??????? deniedExtensions.put("Image",stringToArrayList(getInitParameter("DeniedExtensionsImage")));
???????
??????? allowedExtensions.put("Flash",stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
??????? deniedExtensions.put("Flash",stringToArrayList(getInitParameter("DeniedExtensionsFlash")));
???????
??????? if(debug) System.out.println("---- SimpleUploaderServlet initialization completed ----\r\n");
???????
??? }
???

??? /**
???? * Manage the Upload requests.<br>
???? *
???? * The servlet accepts commands sent in the following format:<br>
???? * simpleUploader?Type=ResourceType<br><br>
???? * It store the file (renaming it in case a file with the same name exists) and then return an HTML file
???? * with a javascript command in it.
???? *
???? */
??? public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

??????? if (debug) System.out.println("--- BEGIN DOPOST ---");

??????? response.setContentType("text/html; charset=UTF-8");
??????? response.setHeader("Cache-Control","no-cache");
??????? PrintWriter out = response.getWriter();
???????

??????? String typeStr=request.getParameter("Type");
???????
??????? String currentPath=baseDir+typeStr;
??????? String currentDirPath=getServletContext().getRealPath(currentPath);
??????? currentPath=request.getContextPath()+currentPath;
???????
??????? if (debug) System.out.println(currentDirPath);
???????
??????? String retVal="0";
??????? String newName="";
??????? String fileUrl="";
??????? String errorMessage="";
???????
??????? if(enabled) {??????
??????????? DiskFileUpload upload = new DiskFileUpload();
??????????? try {
??????????????? List items = upload.parseRequest(request);
???????????????
??????????????? Map fields=new HashMap();
???????????????
??????????????? Iterator iter = items.iterator();
??????????????? while (iter.hasNext()) {
??????????????????? FileItem item = (FileItem) iter.next();
??????????????????? if (item.isFormField())
??????????????????????? fields.put(item.getFieldName(),item.getString());
??????????????????? else
??????????????????????? fields.put(item.getFieldName(),item);
??????????????? }
??????????????? FileItem uplFile=(FileItem)fields.get("NewFile");
??????????????? String fileNameLong=uplFile.getName();
??????????????? fileNameLong=fileNameLong.replace('\\','/');
??????????????? String[] pathParts=fileNameLong.split("/");
??????????????? String fileName=pathParts[pathParts.length-1];
???????????????
??????????????? String nameWithoutExt=getNameWithoutExtension(fileName);
??????????????? String ext=getExtension(fileName);//后綴名
??????????????? String random=String.valueOf((Math.abs((new Random()).nextInt()) % 10000));//生成隨機數
??????????????? String namebydate=String.valueOf(Calendar.getInstance().getTime().getTime())+ random+"."+ext;
??????????????? File pathToSave=new File(currentDirPath,namebydate);
??????????????? fileUrl=currentPath+"/"+namebydate;//返回上傳后的文件路徑
??????????????
??????????????? if(extIsAllowed(typeStr,ext)) {
??????????????????? int counter=1;
??????????????????? while(pathToSave.exists()){//如果服務器存在同名文件
??????????????????????? newName=nameWithoutExt+"("+counter+")"+"."+ext;//新文件名
??????????????????????? fileUrl=currentPath+"/"+newName;
??????????????????????? retVal="201";
??????????????????????? pathToSave=new File(currentDirPath,newName);
??????????????????????? counter++;
??????????????????????? }
??????????????????? uplFile.write(pathToSave);
??????????????? }
??????????????? else {
??????????????????? retVal="202";
??????????????????? errorMessage="";
??????????????????? if (debug) System.out.println("Invalid file type: " + ext);
??????????????? }
??????????? }catch (Exception ex) {
??????????????? if (debug) ex.printStackTrace();
??????????????? retVal="203";
??????????? }
??????? }
??????? else {
??????????? retVal="1";
??????????? errorMessage="This file uploader is disabled. Please check the WEB-INF/web.xml file";
??????? }
???????
??????? //返回文件路徑到文本框
??????? out.println("<script type=\"text/javascript\">");
??????? out.println("window.parent.OnUploadCompleted("+retVal+",'"+fileUrl+"','"+newName+"','"+errorMessage+"');");
??????? out.println("</script>");
??????? out.flush();
??????? out.close();
???
??????? if (debug) System.out.println("--- END DOPOST ---");???
???????
??? }


??? /*
???? * This method was fixed after Kris Barnhoorn (kurioskronic) submitted SF bug #991489
???? */
??? private static String getNameWithoutExtension(String fileName) {
??????????? return fileName.substring(0, fileName.lastIndexOf("."));
??????? }
???????
??? /*
???? * This method was fixed after Kris Barnhoorn (kurioskronic) submitted SF bug #991489
???? */
??? private String getExtension(String fileName) {
??????? return fileName.substring(fileName.lastIndexOf(".")+1);
??? }

?

??? /**
???? * Helper function to convert the configuration string to an ArrayList.
???? */
????
???? private ArrayList stringToArrayList(String str) {
????
???? if(debug) System.out.println(str);
???? String[] strArr=str.split("\\|");
????????
???? ArrayList tmp=new ArrayList();
???? if(str.length()>0) {
???????? for(int i=0;i<strArr.length;++i) {
??????????????? if(debug) System.out.println(i +" - "+strArr[i]);
??????????????? tmp.add(strArr[i].toLowerCase());
??????????? }
??????? }
??????? return tmp;
???? }


??? /**
???? * Helper function to verify if a file extension is allowed or not allowed.
???? */
????
???? private boolean extIsAllowed(String fileType, String ext) {
???????????
??????????? ext=ext.toLowerCase();
???????????
??????????? ArrayList allowList=(ArrayList)allowedExtensions.get(fileType);
??????????? ArrayList denyList=(ArrayList)deniedExtensions.get(fileType);
???????????
??????????? if(allowList.size()==0)
??????????????? if(denyList.contains(ext))
??????????????????? return false;
??????????????? else
??????????????????? return true;

??????????? if(denyList.size()==0)
??????????????? if(allowList.contains(ext))
??????????????????? return true;
??????????????? else
??????????????????? return false;
????
??????????? return false;
???? }

}

.



龍卷風驛站 2006-08-02 17:12 發表評論
]]>
Jfreechart使用http://www.tkk7.com/hackang/archive/2006/07/20/59191.html龍卷風驛站龍卷風驛站Thu, 20 Jul 2006 07:12:00 GMThttp://www.tkk7.com/hackang/archive/2006/07/20/59191.htmlhttp://www.tkk7.com/hackang/comments/59191.htmlhttp://www.tkk7.com/hackang/archive/2006/07/20/59191.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/59191.htmlhttp://www.tkk7.com/hackang/services/trackbacks/59191.htmljfreechart文檔居然是收費的,在網上找了好多資料都是針對1。0之前的版本的,好入容易找到一個1.0下面可以用的


package com.meetexpo.cms.backend.util;

import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.RenderingHints;
import java.io.PrintWriter;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

public class CategoryItemChart {
?public static String generateBarChart(
???????? HttpSession session,
???????? PrintWriter pw,
???????? int w, int h) {
?String filename = null;
?try {
?CategoryDataset dataset=createDataset();
?JFreeChart chart=ChartFactory.createBarChart(
?"世界傻瓜大獎賽",//圖表標題
?"比賽場次",//X軸標題
?"傻瓜程度",//Y軸標題
?dataset,//數據集合
?PlotOrientation.VERTICAL,//圖表顯示方向(水平、垂直)
?true,//是否使用圖例
?false,//是否使用工具提示
?false//是否為圖表增加URL
?);
?
?/*------------配置圖表屬性--------------*/
?// 1,設置整個圖表背景顏色
?chart.setBackgroundPaint(Color.yellow);
?
?
?/*------------設定Plot參數-------------*/
?CategoryPlot plot=chart.getCategoryPlot();
?// 2,設置詳細圖表的顯示細節部分的背景顏色
?plot.setBackgroundPaint(Color.PINK);
?// 3,設置垂直網格線顏色
?plot.setDomainGridlinePaint(Color.black);
?//4,設置是否顯示垂直網格線
?plot.setDomainGridlinesVisible(true);
?//5,設置水平網格線顏色
?plot.setRangeGridlinePaint(Color.yellow);
?//6,設置是否顯示水平網格線
?plot.setRangeGridlinesVisible(true);
?
?/*---------將所有數據轉換為整數形式---------*/
?final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
?rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
?
?/*---------設置是否在柱圖的狀態條上顯示邊框----*/
?CategoryItemRenderer renderer = (CategoryItemRenderer) plot.getRenderer();
?BarRenderer? render=(BarRenderer) plot.getRenderer();
?render.setItemMargin(0.1);
?
?/*---------設置狀態條顏色的深淺漸變-----------*/
??? GradientPaint gp0 = new GradientPaint(
??????????? 0.0f, 0.0f, new Color(255,200,80),
??????????? 0.0f, 0.0f, new Color(255,255,40)
??????????? );
??? GradientPaint gp1 = new GradientPaint(
??????????? 0.0f, 0.0f, new Color(50,255,50),
??????????? 0.0f, 0.0f, new Color(100,255,100)
??????????? );
??? GradientPaint gp2 = new GradientPaint(
??????????? 0.0f, 0.0f, Color.red,
??????????? 0.0f, 0.0f, new Color(255,100,100)
??????????? );
??? GradientPaint gp3 = new GradientPaint(
??????????????? 0.0f, 0.0f, new Color(108,108,255),
??????????????? 0.0f, 0.0f, new Color(150, 150, 200)
??????????????? );
?????????????
??? renderer.setSeriesPaint(0, gp0);
??? renderer.setSeriesPaint(1, gp1);
??? renderer.setSeriesPaint(2, gp2);
??? renderer.setSeriesPaint(3, gp3);

??? /*
???? *
???? * 解決柱狀體與圖片邊框的間距問題
???? *
???? *
???? * */????????????????
??? /*------設置X軸標題的傾斜程度----*/
??? CategoryAxis domainAxis = plot.getDomainAxis();
??? domainAxis.setCategoryLabelPositions(
??? CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
??? );
??? /*------設置柱狀體與圖片邊框的左右間距--*/
??? domainAxis.setLowerMargin(0.01);
??? domainAxis.setUpperMargin(0.01);

??? /*------設置柱狀體與圖片邊框的上下間距---*/
??? ValueAxis rAxis = plot.getRangeAxis();
??? rAxis.setUpperMargin(0.15);
??? rAxis.setLowerMargin(0.15);
???
??? /*---------設置每一組柱狀體之間的間隔---------*/
??? render.setItemMargin(0.0);
??? /*
???? *
???? * 解決柱狀體與圖片邊框的間距問題
???? *
???? *
???? * */?
???
???
???
???
???
??? /*
???? *
???? *
???? * 解決JFREECHART的中文顯示問題
???? *
???? *
???? * */
???
??? /*----------設置消除字體的鋸齒渲染(解決中文問題)--------------*/
??? chart.getRenderingHints().put(
??????????? RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
??????????? );
??? /*----------設置標題字體--------------------------*/
??? TextTitle textTitle = chart.getTitle();
??? textTitle.setFont(new Font("黑體", Font.PLAIN, 20));???????
??? /*------設置X軸坐標上的文字-----------*/
??? domainAxis.setTickLabelFont(new Font("sans-serif",Font.PLAIN,11));
??? /*------設置X軸的標題文字------------*/
??? domainAxis.setLabelFont(new Font("宋體",Font.PLAIN,12));????????
??? /*------設置Y軸坐標上的文字-----------*/
??? rAxis.setTickLabelFont(new Font("sans-serif",Font.PLAIN,12));
??? /*------設置Y軸的標題文字------------*/
??? rAxis.setLabelFont(new Font("黑體",Font.PLAIN,12));
???
??? /*---------設置柱狀體上的顯示的字體---------*/????????
??? renderer.setItemLabelGenerator(new LabelGenerator(0.0));
??? renderer.setItemLabelFont(new Font("宋體",Font.PLAIN,12));
??? renderer.setItemLabelsVisible(true);
???
??? /*
???? *
???? *
???? * 解決JFREECHART的中文顯示問題
???? *
???? *
???? * */????

?/*------得到chart的保存路徑----*/
??? ChartRenderingInfo info = new ChartRenderingInfo(new
??????????? StandardEntityCollection());
?filename = ServletUtilities.saveChartAsPNG(chart, w, h, info, session);
?
?/*------使用printWriter將文件寫出----*/
?ChartUtilities.writeImageMap(pw, filename, info,true);
?pw.flush();
?
?}
?catch (Exception e) {
?System.out.println("Exception - " + e.toString());
?e.printStackTrace(System.out);
?filename = "public_error_500x300.png";
?}
?return filename;
?}
?
?
?/*-------------設置柱狀體頂端的數據顯示--------------*/
?static class LabelGenerator implements CategoryItemLabelGenerator {
?
?private double threshold;
?
?public LabelGenerator(double threshold) {
?this.threshold = threshold;
?}
?
?public String generateLabel(CategoryDataset dataset,
?int row,int column) {
?String result = null;
?final Number value = dataset.getValue(row, column);
?if (value != null) {
?final double v = value.doubleValue();
?if (v > this.threshold) {
?result = value.toString();
?}
?}
?return result;
?}
?
?public String generateRowLabel(CategoryDataset dataset,
?int row){
?return null;
?
?}
?public String generateColumnLabel(CategoryDataset dataset,
?int column){
?return null;
?}
?
?
?
?}
?/*-----------數據集合封裝-------------*/
?private static CategoryDataset createDataset(){
?String s1="笨笨";
?String s2="蛋蛋";
?String s3="傻傻";
?String s4="瓜瓜";
?
?String c1="第一場";
?String c2="第二場";
?String c3="第三場";
?String c4="第四場";
?String c5="第五場";
?
?/*-------------封裝圖表使用的數據集-------------*/
?DefaultCategoryDataset dataset=new DefaultCategoryDataset();
?dataset.setValue(1.0,s1,c1);
?dataset.setValue(2.0,s1,c2);
?dataset.setValue(3.0,s1,c3);
?dataset.setValue(4.0,s1,c4);
?dataset.setValue(5.0,s1,c5);
?
?dataset.setValue(5.0,s2,c1);
?dataset.setValue(4.0,s2,c2);
?dataset.setValue(3.0,s2,c3);
?dataset.setValue(2.0,s2,c4);
?dataset.setValue(1.0,s2,c5);
?
?dataset.setValue(1.0,s3,c1);
?dataset.setValue(2.0,s3,c2);
?dataset.setValue(3.0,s3,c3);
?dataset.setValue(2.0,s3,c4);
?dataset.setValue(1.0,s3,c5);
?
?dataset.setValue(1.0,s4,c1);
?dataset.setValue(2.0,s4,c2);
?dataset.setValue(3.0,s4,c3);
?dataset.setValue(4.0,s4,c4);
?dataset.setValue(5.0,s4,c5);
?
?
?return dataset;
?}
????
?}


JSP代碼如下:
<%@ page contentType="text/html;charset=GBK"%>

<%@ page import="java.io.PrintWriter"%>
<%@ page import="com.meetexpo.cms.backend.util.CategoryItemChart;"%>
<html>
<head>
<title>
</title>
<%
//以下部分為圖象輸出

String fileName=CategoryItemChart.generateBarChart(session,new PrintWriter(out),580,250);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + fileName;

%>

</head>
<body bgcolor="#ffffff">
<table? width="580" border="0" cellspacing="0" cellpadding="0">
? <tr>
??? <td>
????? <img src="<%= graphURL %>" width=580 height=250 border=0
???????? >
??? </td>
? </tr>
</table>
</body>
</html>

類包是jcommon-1.0.0.jar和jfreechart-1.0.0.jar



龍卷風驛站 2006-07-20 15:12 發表評論
]]>
dwr使用實例http://www.tkk7.com/hackang/archive/2006/07/05/56674.html龍卷風驛站龍卷風驛站Wed, 05 Jul 2006 03:06:00 GMThttp://www.tkk7.com/hackang/archive/2006/07/05/56674.htmlhttp://www.tkk7.com/hackang/comments/56674.htmlhttp://www.tkk7.com/hackang/archive/2006/07/05/56674.html#Feedback2http://www.tkk7.com/hackang/comments/commentRss/56674.htmlhttp://www.tkk7.com/hackang/services/trackbacks/56674.html開發環境:eclipse3.1.2? myeclipse4.1.1?? Tomcat5.0.28?? Mysql5.0
dwr類包版本是1.1
步驟一:配置web.xml
?<?xml version="1.0" encoding="UTF-8"?>
<web-app>
??? <servlet>
??????? <servlet-name>action</servlet-name>
??????? <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
??????? <init-param>
??????????? <param-name>config</param-name>
??????????? <param-value>/WEB-INF/struts-config.xml</param-value>
??????? </init-param>
??????? <init-param>
??????????? <param-name>debug</param-name>
??????????? <param-value>3</param-value>
??????? </init-param>
??????? <init-param>
??????????? <param-name>detail</param-name>
??????????? <param-value>3</param-value>
??????? </init-param>
??????? <load-on-startup>0</load-on-startup>
??? </servlet>


??? <servlet-mapping>
??????? <servlet-name>action</servlet-name>
??????? <url-pattern>*.do</url-pattern>
??? </servlet-mapping>
??? <servlet>
??????? <servlet-name>dwr-invoker</servlet-name>
??????? <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
??????? <init-param>
??????????? <param-name>debug</param-name>
??????????? <param-value>true</param-value>
??????? </init-param>
??? </servlet>

??? <servlet-mapping>
??????? <servlet-name>dwr-invoker</servlet-name>
??????? <url-pattern>/dwr/*</url-pattern>
??? </servlet-mapping>
????
??? <context-param>
??????? <param-name>contextConfigLocation</param-name>
??????? <param-value>/WEB-INF/applicationContext.xml
??????? </param-value>
??? </context-param>
??? <listener>
??????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
??? </listener>?
?????
??? <filter>
??????? <filter-name>EncodingFilter</filter-name>
??????? <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
??????? <init-param>
??????????? <param-name>encoding</param-name>
??????????? `
??????????? <param-value>UTF-8</param-value>
??????? </init-param>

??? </filter>
??? <filter-mapping>
??????? <filter-name>EncodingFilter</filter-name>
??????? <url-pattern>/*</url-pattern>
??? </filter-mapping>

????? <error-page>
??????? <error-code>404</error-code>
??????? <location>/404.jsp</location>
??? </error-page>

??? <error-page>
??????? <error-code>500</error-code>
??????? <location>/500.jsp</location>
??? </error-page>

??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-bean</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-logic</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-html</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-tiles</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/ntu</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/ntu.tld</taglib-location>
??? </taglib>

</web-app>

二:spring中注入相關service
<bean id="ajaxTestService" class="com.lion.cms.domain.service.AjaxTestServiceImp">
??????? <property name="commonDAO">
??????????? <ref bean="commonDAO" />
??????? </property>
??? </bean>

三:AjaxTestServiceImp代碼
public class AjaxTestServiceImp implements IAjaxTestService {
??
??? private ICommonDAO commonDAO;

?????
??? public void setCommonDAO(ICommonDAO commonDAO) {
??????? this.commonDAO = commonDAO;
??? }

??? public List getEmployeeById(String deptid) {
??????? DetachedCriteria detachedCriteria=DetachedCriteria.forClass(Employee.class);
??????? detachedCriteria.setFetchMode(Employee.PROP_DEPTID,FetchMode.JOIN);
??????? detachedCriteria.add(Restrictions.eq(Employee.PROP_DEPTID+".id",deptid));
??????? List result=commonDAO.findByCriteria(detachedCriteria);
??????? return result;
???????
??? }
}

四:dwr.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "

<dwr>
?<allow>
??<create creator="spring" javascript="ajaxTestService">
???<param name="beanName" value="ajaxTestService" />
???<include method="getEmployeeById" />
??</create>
??????? <convert converter="bean" match="com.lion.cms.domain.pojo.Employee" />
??????? <param name="exclude" value="com.lion.cms.domain.pojo.Dept"/>
?</allow>
</dwr>

五:jsp頁面
<html:select styleId="deptid" property="deptid" onchange="loadEmployList(this.value)">
??????????????? <html:optionsCollection name="deptlist" label="deptname" value="id"/>
??????????? </html:select>
??????????? <html:select property="employee" styleId="employee">
??????????? <html:option value="" >請選擇</html:option>
??????????? </html:select>????

<script type="text/javascript">
<!--
??? // 加載employee下拉列表。
??? function loadEmployList(deptid){
??????? if(deptid==null||deptid==''){
??????? clearEmployeeSel();
??????? return;
??????? }
??????? ajaxTestService.getEmployeeById(loadEmployListCallback,deptid);
??? }
??? var loadEmployListCallback=function(items){
??????? clearEmployeeSel();
??????? DWRUtil.addOptions("employee",items,"id","truename");
??? }
??? function clearEmployeeSel(){
??????? DWRUtil.removeAllOptions("employee");
??????? DWRUtil.addOptions("employee",[{label:'請選擇',value:''}],"value","label");
??? }
//-->
</script>


職工和部門是多對一關系,例子簡單,不詳細敘述了
dwr中spring和hibernate的配置相關幫助文檔:
http://getahead.ltd.uk/dwr/server/spring
http://getahead.ltd.uk/dwr/server/hibernate


dept.hbm.xml代碼如下:
<hibernate-mapping package="com.lion.cms.domain.pojo">
?<class
?? name="Dept"
??table="dept"
?>
?<meta attribute="sync-DAO">false</meta>
???<id
???name="id"
???type="string"
???column="id"
??>
???<generator class="uuid.hex"/>
??</id>

??<property
???name="deptname"
???column="deptname"
???type="string"
???not-null="true"
???length="12"
??/>
??<property
???name="creattime"
???column="creattime"
???type="java.lang.Long"
???not-null="false"
???length="20"
??/>
?


?</class>?
</hibernate-mapping>


employee.hbm.xml代碼如下:

<hibernate-mapping package="com.lion.cms.domain.pojo">
?<class
??name="Employee"
??table="employee"
?>
??<meta attribute="sync-DAO">false</meta>
??<id
???name="id"
???type="string"
???column="Id"
??>
???<generator class="uuid.hex"/>
??</id>

??<property
???name="username"
???column="username"
???type="string"
???not-null="true"
???length="20"
??/>
??<property
???name="password"
???column="password"
???type="string"
???not-null="false"
???length="20"
??/>
??<property
???name="truename"
???column="truename"
???type="string"
???not-null="false"
???length="11"
??/>
??<property
???name="sex"
???column="sex"
???type="string"
???not-null="false"
???length="2"
??/>
??<property
???name="intro"
???column="intro"
???type="string"
???not-null="false"
??/>
??<many-to-one
???name="deptid"
???column="deptid"
???class="Dept"
???not-null="true"
??>
??</many-to-one>


?</class>?
</hibernate-mapping>

用hibernate同步插件可以快速生成po

?



龍卷風驛站 2006-07-05 11:06 發表評論
]]>
畢業設計搞定,論文拼湊中。。。http://www.tkk7.com/hackang/archive/2006/05/17/46577.html龍卷風驛站龍卷風驛站Wed, 17 May 2006 03:01:00 GMThttp://www.tkk7.com/hackang/archive/2006/05/17/46577.htmlhttp://www.tkk7.com/hackang/comments/46577.htmlhttp://www.tkk7.com/hackang/archive/2006/05/17/46577.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/46577.htmlhttp://www.tkk7.com/hackang/services/trackbacks/46577.html???

??? 系統js代碼寫了不少,因為某些功能必須要這樣來實現。

??? 論文寫了1w多字了,早日做好,公司還有事要做。

??? 做項目的過程中得到了公司不少高人的指點,尤其是我師父colky,讓我少走了很多彎路,好多東西也更清晰,謝謝他們。

龍卷風驛站 2006-05-17 11:01 發表評論
]]>
收藏:父子窗口http://www.tkk7.com/hackang/archive/2006/04/30/44152.html龍卷風驛站龍卷風驛站Sun, 30 Apr 2006 02:42:00 GMThttp://www.tkk7.com/hackang/archive/2006/04/30/44152.htmlhttp://www.tkk7.com/hackang/comments/44152.htmlhttp://www.tkk7.com/hackang/archive/2006/04/30/44152.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/44152.htmlhttp://www.tkk7.com/hackang/services/trackbacks/44152.html
看代碼實例:
<script language=javascript>

function outPut()
{
//獲取父窗口的文本信息賦值給text
var text = document.abc.text.value;
//打開子窗口,并且把操作句柄賦值給win變量,以下所有操作都是針對win對象的
var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
//輸出基本信息
win.document.writeln("<title>輸出結果</title>");
win.document.writeln("你的信息是:<p>");
//輸出從父窗口獲取的信息
win.document.writeln(text);
win.document.close();
win.focus();
}
</script>

<form name=abc method=post>
<input type=text name=text size=50>
//調用上面的函數
<input type=button value=提交 onClick="outPut()">

</form>

2。子窗口傳遞參數給父窗口

我們對上面的代碼進行改造:

<script language=javascript>

function outPut()
{
var text = document.abc.text.value;
var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
win.document.writeln("<title>輸出結果</title>");
win.document.writeln("你的信息是:<p>");
win.document.writeln(text);
win.document.writeln("<input type=text name=child value=子窗口信息>");

//對子窗口本身操作,使用self對象,對父窗口操作使用opener對象,這是關鍵
//把子窗口中表單的值回傳給父窗口,取代父窗口表單以前的值,然后關閉子窗口
win.document.writeln("<input type=button value=關閉自己 onClick='window.opener.abc.text.value=self.child.value;self.close()'>");
//可以控制關閉父窗口
win.document.writeln("<input type=button value=關閉父窗口 onClick='window.opener.opener=null;window.opener.close()'>");
//刷新父窗口
win.document.writeln("<input type=button value=刷新父窗口 onClick='window.opener.location.reload()'>");

win.document.close();
win.focus();
}
</script>

<form name=abc method=post>
<input type=text name=text size=50>
<input type=button value=提交 onClick="outPut()">

</form>


龍卷風驛站 2006-04-30 10:42 發表評論
]]>
做個編碼隨意的程序員http://www.tkk7.com/hackang/archive/2006/04/27/43505.html龍卷風驛站龍卷風驛站Thu, 27 Apr 2006 02:51:00 GMThttp://www.tkk7.com/hackang/archive/2006/04/27/43505.htmlhttp://www.tkk7.com/hackang/comments/43505.htmlhttp://www.tkk7.com/hackang/archive/2006/04/27/43505.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/43505.htmlhttp://www.tkk7.com/hackang/services/trackbacks/43505.html

龍卷風驛站 2006-04-27 10:51 發表評論
]]>
關于DetachedCriteria,今天的一小發現http://www.tkk7.com/hackang/archive/2006/04/24/42827.html龍卷風驛站龍卷風驛站Mon, 24 Apr 2006 06:26:00 GMThttp://www.tkk7.com/hackang/archive/2006/04/24/42827.htmlhttp://www.tkk7.com/hackang/comments/42827.htmlhttp://www.tkk7.com/hackang/archive/2006/04/24/42827.html#Feedback2http://www.tkk7.com/hackang/comments/commentRss/42827.htmlhttp://www.tkk7.com/hackang/services/trackbacks/42827.html比較一個屬性可以這樣:
detachedCriteria.add(Restrictions.eq(XXX.PROP_ID,Integer.parseInt(id)));

如果比較的屬性本身類型是對象,那么可以這樣

detachedCriteria.add(Restrictions.eq(XXX.PROP_BM+".id",Integer.parseInt(bmid)));

以上面的語句為例,如果我比較其他屬性
detachedCriteria.add(Restrictions.eq(XXX.PROP_BM+".bmmc",bmmc));

這樣是不行的

解決方法:先定義一個別名
detachedCriteria.createAlias(XXX.PROP_BM, "bm");
然后可以這樣使用了
detachedCriteria.add("bm.bmmc",bmmc));


ps:個人總結:不使用別名,本身是對象的屬性后面只能跟其主鍵屬性,比較其他屬性要用別名。個人觀點,還沒有得到確認




龍卷風驛站 2006-04-24 14:26 發表評論
]]>
JS中文參數傳遞http://www.tkk7.com/hackang/archive/2006/04/14/41059.html龍卷風驛站龍卷風驛站Fri, 14 Apr 2006 04:13:00 GMThttp://www.tkk7.com/hackang/archive/2006/04/14/41059.htmlhttp://www.tkk7.com/hackang/comments/41059.htmlhttp://www.tkk7.com/hackang/archive/2006/04/14/41059.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/41059.htmlhttp://www.tkk7.com/hackang/services/trackbacks/41059.html

接受方: String? EmployeeName =new? String(httpServletRequest.getParameter("EmployeeName").toString().getBytes("ISO8859-1"));


龍卷風驛站 2006-04-14 12:13 發表評論
]]>
讀取資源文件內容http://www.tkk7.com/hackang/archive/2006/03/28/37764.html龍卷風驛站龍卷風驛站Tue, 28 Mar 2006 04:47:00 GMThttp://www.tkk7.com/hackang/archive/2006/03/28/37764.htmlhttp://www.tkk7.com/hackang/comments/37764.htmlhttp://www.tkk7.com/hackang/archive/2006/03/28/37764.html#Feedback0http://www.tkk7.com/hackang/comments/commentRss/37764.htmlhttp://www.tkk7.com/hackang/services/trackbacks/37764.html...........

import org.apache.struts.util.MessageResources;?
............
............
private static MessageResources MESSAGE = MessageResources.getMessageResources(
??? "ApplicationResources");
?
??? public static String getMessage(Locale locale, String key){
??????? return MESSAGE.getMessage(locale,key);
??? }
???
??? public static String getMessage(HttpServletRequest request,? String key ){
??????? Locale locale = request.getLocale();
??????? return getMessage( locale, key);
???????
??? }





如在JSP頁面可這樣讀取? <%=XxxUtils.getMessage(request,"you message ")%>

龍卷風驛站 2006-03-28 12:47 發表評論
]]>
主站蜘蛛池模板: 免费污视频在线观看| 手机在线免费视频| 亚洲中文字幕日本无线码| 国产大片91精品免费看3| 最新久久免费视频| 亚洲 日韩 色 图网站| 亚洲午夜精品久久久久久浪潮| 可以免费观看的国产视频| 亚洲人成未满十八禁网站| 亚洲日本va在线视频观看| 99久久久国产精品免费无卡顿| 黄色毛片视频免费| 亚洲电影免费观看| 亚洲性日韩精品一区二区三区 | 亚洲春色在线视频| 久久久久久国产a免费观看黄色大片| 黄色一级视频免费| 亚洲国产精品久久人人爱| 亚洲精品麻豆av| 24小时免费直播在线观看| 久久精品乱子伦免费| 美女免费精品高清毛片在线视| 久久久亚洲欧洲日产国码aⅴ| 无码专区一va亚洲v专区在线| 久久精品国产免费观看| 成人妇女免费播放久久久| 亚洲精品无码成人片久久不卡| 久久亚洲精品成人综合| 亚洲国产成人久久综合一区77| 无码国产精品久久一区免费| 日本在线免费观看| 一级特级女人18毛片免费视频| 国产精品亚洲综合久久| 97亚洲熟妇自偷自拍另类图片| 亚洲综合精品网站| 四虎影视永久免费观看地址| 日本三级2019在线观看免费| 99在线视频免费| 可以免费观看的毛片| 在线观看免费视频网站色| 一级美国片免费看|