myeclipse java项目怎么运行_Myeclipse怎样创建并运行web项目

如何建立一个web jsp项目;当运行的时候回自动启动端口9090的服务

1.通过页面来显示内容

或者运行指定的.jsp

2.参照文档引入 各种jar包;引入各种layui的.css文件

3.在src中建立文件夹

the basepath is:

/com/bigdata/log/controller

/com/bigdata/log/dao

/com/bigdata/log/service

在里面建立hbase相关的类,定义不同功能的函数

4.我想在.js中使用 .do,但是如何配置呢?

在webBoot/WEB-INF/web.xml中添加下面的就打不开正常的index.jsp了

--4.1正常显示index.jsp页面

Pro_jsp

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

--4.2提示错误显示页面

Pro_jsp

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

action

*.do

--5.(20200814)

SpringMVC中jsp怎么调用controller中的某个方法

Spring MVC中jsp要调用baicontroller的某个方法需要用ajax或者dudwr来实现。

ajax举例:

var param="userIdSet="+"";

$.ajax({

url: "url 什么zhi点do,或者action",

// 数据发送方式

type: "post",

// 接受数据格式

dataType : "json",

// 要传dao递的数据

data :param,

// 回调函数,接受服务器端返回给客户端的值,即result值

success : function a(result){

回调

});

其中url参数就是controller在web.xml映射的.do或者.action。

里面对应的方法就调用到了。

--------------------begin

首先定义servlet

action

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:spring.xml

1

然后再在中使用它

action

*.do

action

*.view

--------------------end

--20200817经过肖剑的指导,需要增加 applicationContext.xml文件内容如下这个功能用来连接.do

--20200817 今天写了一个方法,把图片写到了指定的文件夹

--step1

///begin 定义工具类,来获取当前Tomcat编译以后的路径,这个和java工程所在的路径不同,一个是java源文件路径,一个是

//javac编译以后的字节码路径,java图片是存放在字节码文件里面的

package com.idt.tools;

import java.io.File;

import java.net.URLDecoder;

public class RootPath {

static public String  getWebRootPath(){

String path = Thread.currentThread().getContextClassLoader().getResource("").getFile();

File file = new File(path);

path = file.getParentFile().getParentFile().getAbsolutePath();

try {

path = URLDecoder.decode(path, "UTF-8");

path = path.replaceAll("\\\\", "/") ;

} catch (Exception e) {

}

return path ;

}

}

///end

--step2

//引入工具类

import com.idt.tools.*;

//各种代码begin

//保存文件到指定文件夹

saveImageAsOtherDir(file,name);

//各种代码end

--step3

/***

* 20200817 向指定的编译环境path文件夹保存图片文件

* @param file

* @param filename

* @throws Exception

*/

public void saveImageAsOtherDir(MultipartFile file, String filename) throws Exception {

File f = null;

if(file.equals("")||file.getSize()<=0){

file = null;

}else{

InputStream ins = file.getInputStream();

//使用工具类方法

String path = new RootPath().getWebRootPath();

//下面的是linux的写法

//f=new File("\\Pro_jsp\\src\\com\\bigdata\\log\\img\\1.png");

//下面的是windows中获取的路径,需要指定d:\是哪个盘符

//f=new File("d:\\1.png"); copy成功

//获取文件的扩展名

int i = filename.lastIndexOf(".");

String extName = filename.substring(i);

//为了防止文件名重复,对文件名生成一个uuid

String uuid = UUID.randomUUID().toString().replace("-", "");

//文件编译以后的path,放在webRoot下面  D:\Tomcat8.0-dashuju\webapps\Pro_jsp\comm\img\ahphj9871023iuoiausdf0871234.png

String tgt_file = path + "\\comm\\img\\" + uuid + extName;

//构造目标文件

f=new File(tgt_file);

try {

//构造目标文件流对象

FileOutputStream os = new FileOutputStream(f,true);

int bytesRead = 0;

byte[] buffer = new byte[8192];

while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {

os.write(buffer, 0, bytesRead);

}

os.close();

ins.close();

} catch (Exception e) {

e.printStackTrace();

}

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值