#massage_box {
position: absolute;
left: expression((body.clientWidth-350)/ 2 );
top: expression((body.clientHeight-200)/ 2 );
width: 350px;
height: 200px;
z-index: 2;
visibility: hidden
}
#mask {
position: absolute;
top: 0;
left: 0;
width: expression(body.scrollWidth);
height: expression(body.scrollHeight);
background: #d3ddea;
filter: ALPHA(opacity =50);
z-index: 1;
visibility: hidden
}
//数据写入Intent
Intent openWelcomeActivityIntent=new Intent();
Bundle myBundelForName=new Bundle();
myBundelForName.putString("Key_Name",inName.getText().toString());
myBundelForName.putString("Key_Age",inAge.getText().toString());
openWelcomeActivityIntent.putExtras(myBundelForName);
openWelcomeActivityIntent.setClass(AndroidBundel.this, Welcome.class);
startActivity(openWelcomeActivityIntent);
//从Intent 中获取数据
Bundle myBundelForGetName=this.getIntent().getExtras();
String name=myBundelForGetName.getString("Key_Name");
package zyf.Android.Study;
import ……
import android.content.Intent;
import android.net.Uri;
import android.view.View.OnClickListener;
public class AndroidStudy_TWO extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText inName = (EditText) findViewById(R.id.name);
final TextView result = (TextView) findViewById(R.id.result);
Button button_Start_Browser = (Button) findViewById(R.id.submit_toNET);
Button button_Login=(Button) findViewById(R.id.show_Login);
Button button_showLoginName=
(Button)findViewById(R.id.submit_toshowLoingName);
button_Start_Browser.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Uri myUri = Uri.parse("http://www.flashwing.net");
Intent openBrowserIntent = new Intent(Intent.ACTION_VIEW,myUri);
startActivity(openBrowserIntent);
}
});
button_Login.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent openWelcomeActivityIntent=new Intent();
openWelcomeActivityIntent.setClass(AndroidStudy_TWO.this,
Welcome.class);
startActivity(openWelcomeActivityIntent);
}
});
button_showLoginName.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
result.setText(inName.getText()+"欢迎您进入");
}
});
}
}
使用Bundle在Activity间传递数据2
从源请求Activity 中通过一个Intent 把一个服务请求传到目标Activity 中
//数据写入Intent
Intent openWelcomeActivityIntent=new Intent();
Bundle myBundelForName=new Bundle();
myBundelForName.putString("Key_Name",inName.getText().toString());
myBundelForName.putString("Key_Age",inAge.getText().toString());
openWelcomeActivityIntent.putExtras(myBundelForName);
openWelcomeActivityIntent.setClass(AndroidBundel.this, Welcome.class);
startActivity(openWelcomeActivityIntent);
//从Intent 中获取数据
Bundle myBundelForGetName=this.getIntent().getExtras();
String name=myBundelForGetName.getString("Key_Name");
myTextView_showName.setText("欢迎您进入:"+name);
private Intent toNextIntent;//Intent 成员声明
toNextIntent=new Intent();//Intent 定义
toNextIntent.setClass(TwoActivityME3.this, SecondActivity3.class);
//设定开启的下一个Activity
startActivityForResult(toNextIntent, REQUEST_ASK);
//开启Intent 时候,把请求码同时传递
-----------------------------------Android 编程基础
3
在源请求Activity 中等待Intent 返回应答结果,通过重载onActivityResult()方法
☻ 第一个参数是你开启请求Intent时的对应请求码,可以自己定义。
☻ 第二个参数是目标Activity返回的验证结果码
☻ 第三个参数是目标Activity返回的Intent
目标Activity 中发送请求结果代码,连同源Activity 请求的数据一同绑定到Bundle
中通过Intent 传回源请求Activity 中
Log与DDMS(查看Log等信息)
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==REQUEST_ASK){
if(resultCode==RESULT_CANCELED){
setTitle("Cancel****");
}else if(resultCode==RESULT_OK){
showBundle=data.getExtras();//从返回的Intent中获得Bundle
Name=showBundle.getString("myName");//从bundle中获得相应数据
text.setText("the name get from the second layout:\n"+Name);
}
}
}
backIntent=new Intent();
stringBundle=new Bundle();
stringBundle.putString("myName", Name);
backIntent.putExtras(stringBundle);
setResult(RESULT_OK, backIntent);//返回Activity结果码
finish();
1、打开cmd输入netca。
2、选择【本地net服务名配置】→下一步。
3、选择【添加】→下一步。
4、在【服务名】中输入你想要连接的服务器上的oracle服务的名字→下一步。
5、选择【tcp】→下一步。
6、在【主机名】中输入你想要连接的服务器ip,端口号不变→下一步。
7、选择【进行测试】→下一步。(当然你也可以选择不测试)
※1测试如果不通过,点击【更改登录】输入一个肯定能登入的【用户名】和【口令】→确定,出现【正在连接...测试成功。】表明测试成功。
※2测试不通过的话,点【上一步】确认你写的【服务名】和【主机名】,确认无误的情况下,确认你要连接的服务器oracle监听服务已经打开。
8、在【net服务名中】输入你想要使用的本地的服务名→下一步。
※就是【sqlplus user/passwd @本地服务名】。
9、选择【否】→下一步。
10、出现【net服务配置完毕】字样→下一步。
11、点击【完成】完成服务配置。
12、在上面服务配置完成以后,在cmd中输入如下命令即可远程登录oracle服务器:
sqlplus user_name/password@本地服务名
一定记住,上面的本地服务名是你第8步写的服务名。
3. JBoss 的安全设置
3.1 jmx-console 登录的用户名和密码设置
默认情况访问 http://localhost:8080/jmx-console 就可以浏览jboss的部署管理的一些信息,不需要输入用户名和密码,使用起来有点安全隐患。下面我们针对此问题对jboss进行配置,使得访问jmx-console也必须要知道用户名和密码才可进去访问。步骤如下:
3.1.1 修改jboss-web.xml文件
打开/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文件,去掉<security-domain>java:/jaas/jmx-console</security-domain>的注释。修改后的该文件内容为:
<jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.-->
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
3.1.2 修改web.xml文件
与3.1.1中的jboss-web.xml同级目录下的web.xml文件,查找到<security-constraint/>节点,去掉它的注释,修改后该部分内容为:
<!-- A security constraint that restricts access to the HTML JMX console
to users with the role JBossAdmin. Edit the roles to what you want and
uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
secured access to the HTML JMX console.-->
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
在此处可以看出,为登录配置了角色JBossAdmin。
3.1.3 修改login-config.xml文件
在第一步中的jmx-console安全域和第二步中的运行角色JBossAdmin都是在login-config.xml中配置,我们在JBoss安装目录/server/default/config下找到它。查找名字为:jmx-console的application-policy:
<application-policy name = "jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">props/jmx-console-users.properties</module-option>
<module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
在此处可以看出,登录的角色、用户等的信息分别在props目录下的jmx-console-roles.properties和jmx-console-users.properties文件中设置,分别打开这两个文件。
其中jmx-console-users.properties文件的内容如下:
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
该文件定义的格式为:用户名=密码,在该文件中,默认定义了一个用户名为admin,密码也为admin的用户,读者可将其改成所需的用户名和密码。
jmx-console-roles.properties的内容如下:
# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin, HttpInvoker
该文件定义的格式为:用户名=角色,多个角色以“,”隔开,该文件默认为admin用户定义了JBossAdmin和HttpInvoker这两个角色。
配置完成后读者可以通过访问: http://localhost:8088/jmx-console/ ,输入jmx-console-roles.properties文件中定义的用户名和密码,访问jmx-console的页面。如图:
package action;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import po.Blog;
import po.Login;
import po.Photo;
import po.Userinfo;
import service.QqrService;
import util.ImageHepler;
import com.opensymphony.xwork2.ActionContext;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class KindEditorAction extends BaseAction {
private static final long serialVersionUID = 1L;
private QqrService qqrService;
// 封装参数
private File imgFile;
private String imgFileFileName;
private String imgFileContentType;
private String fileDir = "/blogimg";
private String imgTitle = "";
private String align;
private int imgWidth = 0;
private int imgHeight = 0;
// 上传kindeditor 图片及压缩
@SuppressWarnings("deprecation")
public String uploadimg() throws Exception {
// TODO Auto-generated method stub
// 只能传图片
try {
if (this.imgFile != null) {
File dir = new File(ServletActionContext.getRequest()
.getRealPath(fileDir));
if (!dir.exists())
dir.mkdir();
Integer login_id = (Integer) ActionContext.getContext()
.getSession().get("login_id");
Date dt = new Date();
File dst = new File(dir.getAbsolutePath() + File.separator
+ login_id + new Date().getTime() + ".jpg");
this.resize_image(this.imgFile, dst);
String id = "context";
String url = ServletActionContext.getRequest().getContextPath()
+ "/" + this.fileDir + "/" + dst.getName();
String border = "0";
String result = "<script type='text/javascript'>";
result += "parent.KE.plugin['image'].insert('" + id + "','"
+ url + "','" + imgTitle + "','" + imgHeight + "','"
+ imgHeight + "','" + border + "','" + align + "'); ";
result += "</script>";
ServletActionContext.getResponse().getWriter().write(result);
} else {
return null;
}
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
// 自己封装的一个把源文件对象复制成目标文件对象
public boolean copy(File src, File dst) {
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(src), 1024);
out = new BufferedOutputStream(new FileOutputStream(dst), 1024);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (null != in) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != out) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 图像压缩
*
* @param fi大图文件
* @param fo将要转换出的小图文件
*/
public boolean resize_image(File fi, File fo) {
try {
// File fi = new File("E:/3.jpg"); // 大图文件
// File fo = new File("E:/333.jpg"); // 将要转换出的小图文件
// AffineTransform transform = new AffineTransform();
BufferedImage bis = ImageIO.read(fi);
int w = bis.getWidth();
// System.out.println(w);
int h = bis.getHeight();
// System.out.println(h);
// double scale = (double) w / h;
int nw = w;
int nh = h;
BufferedImage tag = new BufferedImage(nw, nh,
BufferedImage.TYPE_INT_RGB);
this.imgWidth = tag.getWidth();
this.imgHeight = tag.getHeight();
if (this.imgWidth > 250)
this.imgWidth = 250;
if (this.imgHeight >= 250)
this.imgHeight = 250;
tag.getGraphics().drawImage(bis, 0, 0, nw, nh, null); // 绘制缩小后的图
// 转换为32*32 jpg格式
FileOutputStream newimage = new FileOutputStream(fo); // 输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage);
encoder.encode(tag);
newimage.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public void imageShow(int width, int height, int w, int h) {
int i = width;
int j = height;
width = w;
height = h;
if (i > w) {
float width_Bili = w / i;
float height_Bili = h / j;
float bili = width_Bili;
if (width_Bili < height_Bili) {
bili = width_Bili;
} else {
bili = height_Bili;
}
i = (int) (i * bili);
j = (int) (j * bili);
} else {
if (j > h) {
float bili = (float) (h / j);
i = (int) (i * bili);
j = (int) (j * bili);
}
}
width = i;
height = j;
}
/**
* 图像的缩略
*
*
* width 输出图片大小 height
*
* @param fi大图文件
* @param fo将要转换出的小图文件
*/
public boolean resize_image(File fi, File fo, int width, int height) {
try {
BufferedImage bis = ImageIO.read(fi);
int w = bis.getWidth();
int h = bis.getHeight();
int nw = width;
int nh = height;
BufferedImage tag = new BufferedImage(nw, nh,
BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(bis, 0, 0, nw, nh, null); // 绘制缩小后的图
// 转换为32*32 jpg格式
FileOutputStream newimage = new FileOutputStream(fo); // 输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage);
encoder.encode(tag);
newimage.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
* 图像的等比缩略
*
*
* width 输出图片大小 height
*
* @param fi大图文件
* @param fo将要转换出的小图文件
*/
public boolean geometric_image(File fi, File fo, int width, int height) {
try {
BufferedImage bis = ImageIO.read(fi);
int w = bis.getWidth();
int h = bis.getHeight();
int nw = w;
int nh = h;
if (w > width) {
nw = width;
nh = nw * h / w;
if (nh > height) {
nh = height;
nw = nh * w / h;
}
} else if (h > height) {
nh = height;
nw = nh * w / h;
if (nw > width) {
nw = width;
nh = nw * h / w;
}
}
BufferedImage tag = new BufferedImage(nw, nh,
BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(bis, 0, 0, nw, nh, null); // 绘制缩小后的图
// 转换为32*32 jpg格式
FileOutputStream newimage = new FileOutputStream(fo); // 输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage);
encoder.encode(tag);
newimage.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public String getImgTitle() {
return imgTitle;
}
public void setImgTitle(String imgTitle) {
this.imgTitle = imgTitle;
}
public String getAlign() {
return align;
}
public void setAlign(String align) {
this.align = align;
}
public QqrService getQqrService() {
return qqrService;
}
public void setQqrService(QqrService qqrService) {
this.qqrService = qqrService;
}
public File getImgFile() {
return imgFile;
}
public void setImgFile(File imgFile) {
this.imgFile = imgFile;
}
public String getImgFileFileName() {
return imgFileFileName;
}
public void setImgFileFileName(String imgFileFileName) {
this.imgFileFileName = imgFileFileName;
}
public String getImgFileContentType() {
return imgFileContentType;
}
public void setImgFileContentType(String imgFileContentType) {
this.imgFileContentType = imgFileContentType;
}
public String getFileDir() {
return fileDir;
}
public void setFileDir(String fileDir) {
this.fileDir = fileDir;
}
}