求学快递网 JAVA培训
发布资讯
您当前的位置:首页 > JAVA培训 > Java经验分享:初学者学习经验总结

Java经验分享:初学者学习经验总结

上传时间: 2017-11-11 10:03:49 来源:用户上传
浏览量:1249 评论数:0 举报
导读: 小编为您搜集整理了"Java经验分享:初学者学习经验总结“,供您参考,希望对大家有所帮助!
configure libraries-->new--->name:里面填写j2ee,Location:里面默认的旧可以了。---->add-->选在j2ee安装路径,选中lib文件夹--ok--oK.

  2:)返回到configure libraries也面后,选中Required Libraries-->add--》选中你刚才创建的j2ee,点ok就可以了。

  然后配置webshpere应用服务器和database pilot:

  第一步:tools-->enterprise setup-->Application servers设置安装路径以及IBM的JAVA路径,DB2你自己看着办

  第二步:project-->Defaults project properties里servers选择Ws4.0,应该可以用了

  webshpere4.0不支持ejb2.0,webshpere5.0支持。

  配置database pilot

  第一步:添加类库tools-->config libraries添加你的数据库驱动程序类

  第二步:tools-->enterprise setup-->Database Drivers里面添加你刚添加的那个类库

  第三步:重启JBilder后,tools-->database pilot-->option-->drivers,添加驱动程序

  第四步:在database pilot点新建就可以了,driver:COM.ibm.db2.jdbc.app.DB2Driver。url:jdbc:db2:db_sdbc.(db_sdbc为服务器上的db2数据库).

  7:解决java中文问题:

  针对applet和awt:

  1:)

  Font f = new Font(UIResource.getString( "Default_font"),Font.PLAIN,12);

  UIManager.put("Label.font",f);

  UIManager.put("Label.foreground",Color.black);

  UIManager.put("Button.font",f);

  UIManager.put("Menu.font",f);

  UIManager.put("MenuItem.font",f);

  UIManager.put("List.font",f);

  UIManager.put("CheckBox.font",f);

  UIManager.put("RadioButton.font",f);

  UIManager.put("ComboBox.font",f);

  UIManager.put("TextArea.font",f);

  2:)

  Font f = new Font("隶书",Font.PLAIN,15);

  UIManager.put("Button.font",font);

  UIManager.put("ToggleButton.font",font);

  UIManager.put("RadioButton.font",font);

  UIManager.put("CheckBox.font",font);

  UIManager.put("ColorChooser.font",font);

  UIManager.put("ToggleButton.font",font);

  UIManager.put("ComboBox.font",font);

  UIManager.put("ComboBoxItem.font",font);

  UIManager.put("InternalFrame.titleFont",font);

  UIManager.put("Label.font",font);

  UIManager.put("List.font",font);

  UIManager.put("MenuBar.font",font);

  UIManager.put("Menu.font",font);

  UIManager.put("MenuItem.font",font);

  UIManager.put("RadioButtonMenuItem.font",font);Java认证考试UIManager.put("CheckBoxMenuItem.font",font);

  UIManager.put("PopupMenu.font",font);

  UIManager.put("OptionPane.font",font);

  UIManager.put("Panel.font",font);

  UIManager.put("ProgressBar.font",font);

  UIManager.put("ScrollPane.font",font);

  UIManager.put("Viewport",font);

  UIManager.put("TabbedPane.font",font);

  UIManager.put("TableHeader.font",font);

  UIManager.put("TextField.font",font);

  UIManager.put("PasswordFiled.font",font);

  UIManager.put("TextArea.font",font);

  UIManager.put("TextPane.font",font);

  UIManager.put("EditorPane.font",font);

  UIManager.put("TitledBorder.font",font);

  UIManager.put("ToolBar.font",font);

  UIManager.put("ToolTip.font",font);

  UIManager.put("Tree.font",font);

  3:)针对jsp和servlet:

  解决办法:

  第一:

  在jsp页面加入:

  <%@ page contentType="text/html; charset=gb2312" %>

  或者在servlet里面

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

  response.setContentType("text/html; charset=gb2312");//这是重要的

  上面的如果在不行就用如下的方法在数据入库前进行调用:

  public static String UnicodeToChinese(String s){

  try{

  if(s==null||s.equals("")) return "";

  String newstring=null;

  newstring=new String(s.getBytes("ISO8859_1"),"gb2312");

  return newstring;

  }

  catch(UnsupportedEncodingException e)

  {

  return s;

  }

  }

  public static String ChineseToUnicode(String s){

  try{

  if(s==null||s.equals("")) return "";

  String newstring=null;

  newstring=new String(s.getBytes("gb2312"),"ISO8859_1");

  return newstring;

  }

  catch(UnsupportedEncodingException e)

  {

  return s;

  }

  }

  3:)解决weblogic/webshpere中文问题:

  在web.xml文件中需要配置中文环境。r

  

  weblogic.httpd.inputCharset./*

  GB2312

  

  4:)javamail附件中文乱码:

  /*

  @从BodyPart中提取使用ISO-8859-1编吗的文件名

  @因为BodyPart.getFilename()过程已经对文件名作了一次编码,有时不能直接使用

  */

  public static String getISOFileName(Part body){

  //设置一个标志,判断文件名从Content-Disposition中获取还是从Content-Type中获取

  boolean flag=true;

  if(body==null){

  return null;

  }

  String cdis;

  try{

  cdis=body.getHeader("Content-Disposition");

  }

  catch(Exception e){

  return null;

  }

  if(cdis==null){

  flag=false;

  }

  if(!flag){

  try{

  cdis=body.getHeader("Content-Type");

  }

  catch(Exception e){

  return null;

  }

  }

  if(cdis==null){

  return null;

  }

  if(cdis[0]==null){

  return null;

  }

  //从Content-Disposition中获取文件名

  if(flag){

  int pos=cdis[0].indexOf("filename=");

  if(pos<0){

  return null;

  }

  //如果文件名带引号

  if(cdis[0].charAt(cdis[0].length()-1)==´"´){

  return cdis[0].substring(pos+10,cdis[0].length()-1);

  }

  return cdis[0].substring(pos+9,cdis[0].length());

  }

  else{

  int pos=cdis[0].indexOf("name=");

  if(pos<0){

  return null;

  }

  //如果文件名带引号

  if(cdis[0].charAt(cdis[0].length()-1)==´"´){

  return cdis[0].substring(pos+6,cdis[0].length()-1);

  }

  return cdis[0].substring(pos+5,cdis[0].length());

  }

  }

-->

  1:jdk开发中系统环境变量设置:

  方法

  Win2000中:

  右键我的电脑--》属性--》高级--》环境环境变量

  classpath=.;jdk安装目“lib

  path=jdk安装目录“bin

  注意:一定不可忽略"."。

  Win98中:

  修改autocexe.bat 就是修改自动批处理文件。

  添加:

  set classpath=.;jdk安装目“lib

  set path=jdk安装目录“bin;%path%

  2:(前提设置好了系统环境变量)

  不带包的编译,相当简单:

  javac 类名.java

  java 类名

  关于带包的编译问题:

  如果你的类是带包的,应该用如下方法编译:

  javac -d 包的父目录 类名.java

  java 包名.类名

  3:Tomcat服务器配置:

  1):设置好系统环境变量。

  2):JAVA_HOME=G:“JBuilder6“jdk1.3.1

  G:“JBuilder6“jdk1.3.1为jdk安装目录

  3):TOMCAT_HOME=tomcat安装目录

  4:修改serlet而不重新启动tomcat

  修改

  %TOMCAT_HOME%“conf“server.xml

  大致

  

  其中reloadable就是配置是否自动reload的,把它设为true,如果没有这一项,加上。

  5:修改webshpere中的servlet而不重新启动服务:

  修改..“WEB-INF下面的web.xml:

  加入其中reloadInterval="3" reloadingEnabled="true" fileServingEnabled="true" directoryBrowsingEnabled="true" serveServletsByClassnameEnabled="true"是主要的,reloadInterval="3" reloadingEnabled="true" 是说修改后3秒自动重新载

  入。

  6:配置jbuilder6+webshpere4.0AE,其实jb7可以参照:

  首先安装j2ee,然后把j2ee加入到jb的libraries里面。方法如下

  1:)tools--->configure libraries-->new--->name:里面填写j2ee,Location:里面默认的旧可以了。---->add-->选在j2ee安装路径,选中lib文件夹--ok--oK.

  2:)返回到configure libraries也面后,选中Required Libraries-->add--》选中你刚才创建的j2ee,点ok就可以了。

  然后配置webshpere应用服务器和database pilot:

  第几步:tools-->enterprise setup-->Application servers设置安装路径以及IBM的JAVA路径,DB2你自己看着办

  第二步:project-->Defaults project properties里servers选择Ws4.0,应该可以用了

  webshpere4.0不支持ejb2.0,webshpere5.0支持。

  配置database pilot

  第几步:添加类库tools-->config libraries添加你的数据库驱动程序类

  第二步:tools-->enterprise setup-->Database Drivers里面添加你刚添加的那个类库

  第三步:重启JBilder后,tools-->database pilot-->option-->drivers,添加驱动程序

  第四步:在database pilot点新建就可以了,driver:COM.ibm.db2.jdbc.app.DB2Driver。url:jdbc:db2:db_sdbc.(db_sdbc为服务器上的db2数据库).

  7:解决java中文问题:

  针对applet和awt:

  1:)

  Font f = new Font(UIResource.getString( "Default_font"),Font.PLAIN,12);

  UIManager.put("Label.font",f);

  UIManager.put("Label.foreground",Color.black);

  UIManager.put("Button.font",f);

  UIManager.put("Menu.font",f);

  UIManager.put("MenuItem.font",f);

  UIManager.put("List.font",f);

  UIManager.put("CheckBox.font",f);

  UIManager.put("RadioButton.font",f);

  UIManager.put("ComboBox.font",f);

  UIManager.put("TextArea.font",f);

  2:)

  Font f = new Font("隶书",Font.PLAIN,15);

  UIManager.put("Button.font",font);

  UIManager.put("ToggleButton.font",font);

  UIManager.put("RadioButton.font",font);

  UIManager.put("CheckBox.font",font);

  UIManager.put("ColorChooser.font",font);

  UIManager.put("ToggleButton.font",font);

  UIManager.put("ComboBox.font",font);

  UIManager.put("ComboBoxItem.font",font);

  UIManager.put("InternalFrame.titleFont",font);

  UIManager.put("Label.font",font);

  UIManager.put("List.font",font);

  UIManager.put("MenuBar.font",font);

  UIManager.put("Menu.font",font);

  UIManager.put("MenuItem.font",font);

  UIManager.put("RadioButtonMenuItem.font",font);Java认证考试UIManager.put("CheckBoxMenuItem.font",font);

  UIManager.put("PopupMenu.font",font);

  UIManager.put("OptionPane.font",font);

  UIManager.put("Panel.font",font);

  UIManager.put("ProgressBar.font",font);

  UIManager.put("ScrollPane.font",font);

  UIManager.put("Viewport",font);

  UIManager.put("TabbedPane.font",font);

  UIManager.put("TableHeader.font",font);

  UIManager.put("TextField.font",font);

  UIManager.put("PasswordFiled.font",font);

  UIManager.put("TextArea.font",font);

  UIManager.put("TextPane.font",font);

  UIManager.put("EditorPane.font",font);

  UIManager.put("TitledBorder.font",font);

  UIManager.put("ToolBar.font",font);

  UIManager.put("ToolTip.font",font);

  UIManager.put("Tree.font",font);

  3:)针对jsp和servlet:

  解决办法:

  第几:

  在jsp页面加入:

  <%@ page contentType="text/html; charset=gb2312" %>

  或者在servlet里面

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

  response.setContentType("text/html; charset=gb2312");//这是重要的

  上面的如果在不行就用如下的方法在数据入库前进行调用:

  public static String UnicodeToChinese(String s){

  try{

  if(s==null||s.equals("")) return "";

  String newstring=null;

  newstring=new String(s.getBytes("ISO8859_1"),"gb2312");

  return newstring;

  }

  catch(UnsupportedEncodingException e)

  {

  return s;

  }

  }

  public static String ChineseToUnicode(String s){

  try{

  if(s==null||s.equals("")) return "";

  String newstring=null;

  newstring=new String(s.getBytes("gb2312"),"ISO8859_1");

  return newstring;

  }

  catch(UnsupportedEncodingException e)

  {

  return s;

  }

  }

  3:)解决weblogic/webshpere中文问题:

  在web.xml文件中需要配置中文环境。r

  

  weblogic.httpd.inputCharset./*

  GB2312

  

  4:)javamail附件中文乱码:

  /*

  @从BodyPart中提取使用ISO-8859-1编吗的文件名

  @因为BodyPart.getFilename()过程已经对文件名作了一次编码,有时不能直接使用

  */

  public static String getISOFileName(Part body){

  //设置一个标志,判断文件名从Content-Disposition中获取还是从Content-Type中获取

  boolean flag=true;

  if(body==null){

  return null;

  }

  String cdis;

  try{

  cdis=body.getHeader("Content-Disposition");

  }

  catch(Exception e){

  return null;

  }

  if(cdis==null){

  flag=false;

  }

  if(!flag){

  try{

  cdis=body.getHeader("Content-Type");

  }

  catch(Exception e){

  return null;

  }

  }

  if(cdis==null){

  return null;

  }

  if(cdis[0]==null){

  return null;

  }

  //从Content-Disposition中获取文件名

  if(flag){

  int pos=cdis[0].indexOf("filename=");

  if(pos<0){

  return null;

  }

  //如果文件名带引号

  if(cdis[0].charAt(cdis[0].length()-1)==´"´){

  return cdis[0].substring(pos+10,cdis[0].length()-1);

  }

  return cdis[0].substring(pos+9,cdis[0].length());

  }

  else{

  int pos=cdis[0].indexOf("name=");

  if(pos<0){

  return null;

  }

  //如果文件名带引号

  if(cdis[0].charAt(cdis[0].length()-1)==´"´){

  return cdis[0].substring(pos+6,cdis[0].length()-1);

  }

  return cdis[0].substring(pos+5,cdis[0].length());

  }

  }

赞(20) 不喜欢(0) 收藏
免责声明 : 本站为免费网络服务提供商,为注册用户提供免费信息存储空间服务,网站所有信息均为用户自行发布并由用户承担相应法律责任,本站不对用户发布的信息进行修改及审核,不对发布信息的真实性及合法性负责,如涉及侵权或者信息违法的请你及时与本站联系进行删除以保障你的合法权益。详情可阅读本站免责声明

相关推荐:

发表评论 用户评价仅供其表达个人意见,与本站无关

还可以输入235个字

最热评论

new 最新评论

大家都在看
>
热门课程培训

建议反馈表

非常感谢您给我们提出的问题或建议,我们会尽快处理! ×

反馈类型:

问题描述:

您的联系方式:

客服电话:

×
投诉举报
选择举报类型
×
投诉举报
填写并确认举报信息
为了确保问题能及时得到处理,请务必保证您提交的信息真实有效、清晰完整

*举报理由:

*举报描述:

截图证明:

×
投诉举报
填写并确认举报信息
为了确保问题能及时得到处理,请务必保证您提交的信息真实有效、清晰完整

*举报描述:

*原文链接:

联系方式:

截图证明:

×
投诉举报

当您发现本站有涉及个人的侵权内容时,建议您先尝试与当事人沟通解决问题。 如果您无法联系到当事人,您可通过此渠道提交举报诉求。

根据求学快递网侵权举报规范,您需要向我们提交您的个人信息,其中包括身份证明。如您确认已准备齐全,可点击下方按钮进入诉求提交页。

如果您举报的仅仅是辱骂等不友善内容,无需提交证明资料,可返回上一步点击【包含有害内容>辱骂、歧视、挑衅和诽谤等不友善信息】直接举报。
×
投诉举报

当您发现本站有涉及企业的侵权内容时,建议您先尝试与当事人沟通解决问题。 如果您无法联系到当事人,您可通过此渠道提交举报诉求。

根据求学快递网侵权举报规范,您需要向我们提交您企业和个人的证明材料。如您确认已准备齐全,可点击下方按钮进入诉求提交页。

如果您举报的仅仅是辱骂等不友善内容,无需提交证明资料,可返回上一步点击【包含有害内容>辱骂、歧视、挑衅和诽谤等不友善信息】直接举报。
×
投诉举报
填写并确认举报信息
为了确保问题能及时得到处理,请务必保证您提交的信息真实有效、清晰完整

*举报理由:

举报描述:

截图证明: