全是代码,整个逻辑都在里面,可贴纹理
/**
* geoJSON 生成dae 接口
* ...
*
* @author qzblm
*/
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jetbrains.annotations.NotNull;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.triangulate.DelaunayTriangulationBuilder;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletResponse;
import java.awt.geom.Point2D;
import java.io.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ColladaExporter{
/**
* 导出obj格式。
*
* @param geoJSON 示例参数 {"features"}
* @return 示例返回值生成的obj的zip
*/
public static String LoadObj(String geoJSON ) throws IOException {
// String filePath = "E:\\tiff\\one.json";
char randomLetter = generateRandomLetter();
CreateDirPath("D:\\objs\\");
String createPath = "D:\\objs\\"+randomLetter+randomLetter+randomLetter;
CreateDirPath(createPath);
String objFilename = createPath+"\\models.dae";
CreateDir(objFilename);//创造文件obj
ObjectMapper objectMapper = new ObjectMapper();
JsonNode geoJson = objectMapper.readTree(geoJSON);
JsonNode features = geoJson.get("features");
List<String> objAll = new ArrayList<>();
List<String> objVT = new ArrayList<>();
List<String> objVn = new ArrayList<>();
List<String> mtl = new ArrayList<>();
String Collada ="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n" +
"<COLLADA xmlns=\"http://www.collada.org/2005/11/COLLADASchema\" version=\"1.4.1\">\n";
String asset =" <asset>\n" +
" <contributor>\n" +
" <author>GDobj2Collada</author>\n" +
" <authoring_tool>GDobj2Collada Exporter</authoring_tool>\n" +
" </contributor>\n" +
" <created>2023-10-07T08:59:24</created>\n" +
" <modified>2023-10-07T08:59:24</modified>\n" +
" <unit name=\"meter\" meter=\"1\" />\n" +
" <up_axis>Y_UP</up_axis>\n" +
" </asset>\n";
String library_images ="<library_images>\n";
String library_effects = " <library_effects>\n" +
" <effect id=\"DefaultMaterial-fx\" name=\"DefaultMaterial\">\n" +
" <profile_COMMON>\n" +
" <technique sid=\"standard\">\n" +
" <phong>\n" +
" <emission>\n" +
" <color sid=\"emission\">0 0 0 1</color>\n" +
" </emission>\n" +
" <ambient>\n" +
" <color sid=\"ambient\">0 0 0 1</color>\n" +
" </ambient>\n" +
" <diffuse>\n" +
" <color sid=\"diffuse\">0.60000002 0.60000002 0.60000002 1</color>\n" +
" </diffuse>\n" +
" <specular>\n" +
" <color sid=\"specular\">0 0 0 1</color>\n" +
" </specular>\n" +
" <shininess>\n" +
" <float sid=\"shininess\">0</float>\n" +
" </shininess>\n" +
" <transparent>\n" +
" <color sid=\"transparent\">1 1 1 1</color>\n" +
" </transparent>\n" +
" <transparency>\n" +
" <float sid=\"transparency\">1</float>\n" +
" </transparency>\n" +
" <index_of_refraction>\n" +
" <float sid=\"index_of_refraction\">1</float>\n" +
" </index_of_refraction>\n" +
" </phong>\n" +
" </technique>\n" +
" </profile_COMMON>\n" +
" </effect>\n";
String library_materials = " <library_materials>\n" +
" <material id=\"DefaultMaterial\" name=\"DefaultMaterial\">\n" +
" <instance_effect url=\"#DefaultMaterial-fx\"/>\n" +
" </material>\n";
String library_geometries = " <library_geometries>\n";
String library_visual_scenes =" <library_visual_scenes>\n" +
" <visual_scene id=\"models.obj\" name=\"models.obj\">\n";
int objVTs = 0;
int f = 1;
int index = 1;
for(int i =0;i<features.size();i++){
List<String> objV = new ArrayList<>();
List<String> objF = new ArrayList<>();
JsonNode properties = features.get(i).get("properties");
String Z = "0.0";
System.out.println("生成中"+features.get(i).get("id"));
String ZH = properties.get("height").toString();
ZH = ZH.substring(1, ZH.length() - 1);
String floor = properties.get("floor").toString();
floor = floor.substring(1, floor.length() - 1);
double floors = Double.parseDouble(floor);
// JsonNode h2 = objectMapper.readTree(h3.toString().replaceAll("\"", ""));
// JsonNode data2 =features.get(0).get("properties").get("outloop")
JsonNode data2 = objectMapper.readTree(properties.get("outloop").toString().replaceAll("\"", ""));
JsonNode url = properties.get("url");
for(int a =0;a< url.size();a++){
if(url.get(a).toString().length()>2){
loadTextrue(url.get(a).toString(),createPath+"\\texture"+(i+a)+".png");
mtl.add("newmtl material"+(i+a)+"\n");
mtl.add("Ns 250.000000\n");
mtl.add("Ka 1.000000 1.000000 1.000000\n");
mtl.add("Ks 0.500000 0.500000 0.500000\n");
mtl.add("Ke 0.000000 0.000000 0.000000\n");
mtl.add("Ni 1.450000\n");
mtl.add("d 1.000000\n");
mtl.add("illum 2\n");
mtl.add("map_Kd "+"texture"+(i+a)+".png\n");
library_images += "<image id=\"material"+(i+a)+"-diffuse-image\">\n" +
" <init_from>texture"+i+".png</init_from>\n" +
" </image>\n";
}
}
library_effects +=" <effect id=\"material"+i+"-fx\" name=\"material"+i+"\">\n" +
" <profile_COMMON>\n" +
" <newparam sid=\"material"+i+"-diffuse-surface\">\n" +
" <surface type=\"2D\">\n" +
" <init_from>material"+i+"-diffuse-image</init_from>\n" +
" </surface>\n" +
" </newparam>\n" +
" <newparam sid=\"material"+i+"-diffuse-sampler\">\n" +
" <sampler2D>\n" +
" <source>material"+i+"-diffuse-surface</source>\n" +
" </sampler2D>\n" +
" </newparam>\n" +
" <technique sid=\"standard\">\n" +
" <phong>\n" +
" <emission>\n" +
" <color sid=\"emission\">0 0 0 1</color>\n" +
" </emission>\n" +
" <ambient>\n" +
" <color sid=\"ambient\">1 1 1 1</color>\n" +
" </ambient>\n" +
" <diffuse>\n" +
" <texture texture=\"material"+i+"-diffuse-sampler\" texcoord=\"CHANNEL0\" />\n" +
" </diffuse>\n" +
" <specular>\n" +
" <color sid=\"specular\">0.5 0.5 0.5 1</color>\n" +
" </specular>\n" +
" <shininess>\n" +
" <float sid=\"shininess\">250</float>\n" +
" </shininess>\n" +
" <transparent>\n" +
" <color sid=\"transparent\">1 1 1 1</color>\n" +
" </transparent>\n" +
" <transparency>\n" +
" <float sid=\"transparency\">1</float>\n" +
" </transparency>\n" +
" <index_of_refraction>\n" +
" <float sid=\"index_of_refraction\">1.45</float>\n" +
" </index_of_refraction>\n" +
" </phong>\n" +
" </technique>\n" +
" </profile_COMMON>\n" +
" </effect>\n";
library_materials += " <material id=\"material"+i+"\" name=\"material"+i+"\">\n" +
" <instance_effect url=\"#material"+i+"-fx\"/>\n" +
" </material>\n";
List<Double[]> point = new ArrayList<>();
for(int z =0;z<data2.size();z++){
JsonNode data5 = data2.get(z);
if(data5 != null){
Double[] data3 ={
data5.get(0).asDouble(),data5.get(1).asDouble()};
String Z1 = "50.0";
data3[1] = (data3[1]);
data3[0] = (data3[0]);
point.add(data3);
}
}
// 计算面周长
Double perimeter = (double) 0;
List<Double> perimeters = new ArrayList<>();
for(int z = 0;z+1<point.size();z++){
Double[] Around1 = point.get(z);
Double[] Around2 = point.get(z+1);
Point2D.Double p1 = new Point2D.Double( Around1[0], Around1[1]);
Point2D.Double p2 = new Point2D.Double(Around2[0], Around2[1]);
double distance = p1.distance(p2);
perimeter += distance;
perimeters.add(distance);
}
Double perimeter2 = (double) 0;
// point.add(point.get(0));
// 生成周边
for(int z = 0;z+1<point.size();z++){
Double[] Around1 = point.get(z);
Double[] Around2 = point.get(z+1);
perimeter2 += perimeters.get(z);
objVn.add("vn -0.0000 -0.0000 -1.0000\n");
objVT.add(((perimeter2-perimeters.get(z))/perimeter)+" 0.0");
objVT.add(perimeter2/perimeter+" 0.0 ");
objVT.add(perimeter2/perimeter+" 1.0 ");
objVT.add(((perimeter2-perimeters.get(z))/perimeter)+" 1.0 ");
String F1 = objV.size() + " " + (objV.size() + 1)+ " " + (objV.size() + 2)+ " " ;
F1 += objV.size() + " " + (objV.size() + 2)+ " " + (objV.size() + 3);
String V1 = Around1[0] + " " + Z + " " + Around1[1] + " ";
String V2 = Around2[0] + " " + Z + " " + Around2[1] + " ";
String V3 = Around2[0] + " " + ZH + " " + Around2[1] + " ";
String V4 = Around1[0] + " " + ZH + " " + Around1[1] + " ";
f +=1;
objV.add(V1);objV.add(V2);objV.add(V3);objV.add(V4);
objF.add(F1);
}
point.add(point.get(0));
List<Coordinate> coordinateList = new ArrayList<>();
for (int c =0;c<point.size();c++){
coordinateList.add(new Coordinate(point.get(c)[0],point.get(c)[1],0));
}
Coordinate[] coords = coordinateList.toArray(new Coordinate[0]);
GeometryFactory geomFactory = new GeometryFactory();
LinearRing shell = geomFactory.createLinearRing(coords);
Polygon polygon = geomFactory.createPolygon(shell, null);
DelaunayTriangulationBuilder builders = new DelaunayTriangulationBuilder();
builders.setSites(polygon);
GeometryCollection triangles = (GeometryCollection) builders.getTriangles(geomFactory);
// int bc = objV.size();
for (int c = 0; c < triangles.getNumGeometries(); c++) {
Polygon triangle = (Polygon) triangles.getGeometryN(c);
boolean isInnerPolygonContained = polygon.intersects(triangle)&& !polygon.touches(triangle);
if(isInnerPolygonContained){
//生成顶部
objVT.add("0.0 0.0 ");
objVT.add("1.0 0.0 ");
objVT.add("1.0 1.0 ");
String F1 = objV.size() + " " + (objV.size()+1) + " " + (objV.size()+2) + " ";
objVn.add("vn -0.0000 -0.0000 -1.0000\n");
String V1 = triangle.getCoordinates()[0].x + " 0 " + triangle.getCoordinates()[0].y + " ";
String V2 = triangle.getCoordinates()[1].x + " 0 " + triangle.getCoordinates()[1].y + " ";
String V3 = triangle.getCoordinates()[2].x + " 0 " + triangle.getCoordinates()[2].y + " ";
objV.add(V1);objV.add(V2);objV.add(V3);
objF.add(F1);
f +=1;
//生成底部
objVT.add("0.0 0.0 ");
objVT.add("1.0 0.0 ");
objVT.add("1.0 1.0 ");
String F2 = objV.size() + " " + (objV.size()+1) + " " + (objV.size()+2) + " ";
V1 = triangle.getCoordinates()[0].x + " " + ZH + " " + triangle.getCoordinates()[0].y + " ";
V2 = triangle.getCoordinates()[1].x + " " + ZH + " " + triangle.getCoordinates()[1].y + " ";
V3 = triangle.getCoordinates()[2].x + " " + ZH + " " + triangle.getCoordinates()[2].y + " ";
objV.add(V1);objV.add(V2);objV.add(V3);
objF.add(F2);
f +=1;
}
}
objAll.add("o Cylinder_"+index+"\n");
index+=1;
String positions_array = "";
String tex_array ="";
String p = "";
String vcount = "";
String normals_array ="";
for(int b =0;b<objV.size();b++){
positions_array +=objV.get(b) ;
normals_array +="-0 -0 -1 ";
}
for(int b =0;b<objVT.size();b++){
tex_array += objVT.get(b)+" ";
}
for(int b =0;b<objF.size();b++){
p += objF.get(b)+" ";
if(objF.get(b).split(" ").length==6){
vcount += "3 3 ";
}else{
vcount += "3 ";
}
}
objVTs+=objV.size();
library_geometries +=" <geometry id=\"meshId"+i+"\" name=\"meshId"+i+"_name\" >\n" +
" <mesh>\n" +
" <source id=\"meshId"+i+"-positions\" name=\"meshId"+i+"-positions\">\n" +
" <float_array id=\"meshId"+i+"-positions-array\" count=\""+objV.size()*3+"\">" +
positions_array +
" </float_array>\n" +
" <technique_common>\n" +
" <accessor count=\""+objV.size()+"\" offset=\"0\" source=\"#meshId"+i+"-positions-array\" stride=\"3\">\n" +
" <param name=\"X\" type=\"float\" />\n" +
" <param name=\"Y\" type=\"float\" />\n" +
" <param name=\"Z\" type=\"float\" />\n" +
" </accessor>\n" +
" </technique_common>\n" +
" </source>\n";
library_geometries += " <source id=\"meshId"+i+"-normals\" name=\"meshId"+i+"-normals\">\n" +
" <float_array id=\"meshId"+i+"-normals-array\" count=\""+objV.size()*3+"\">\n" +
normals_array +
" </float_array>\n" +
" <technique_common>\n" +
" <accessor count=\"2250\" offset=\"0\" source=\"#meshId"+i+"-normals-array\" stride=\"3\">\n" +
" <param name=\"X\" type=\"float\" />\n" +
" <param name=\"Y\" type=\"float\" />\n" +
" <param name=\"Z\" type=\"float\" />\n" +
" </accessor>\n" +
" </technique_common>\n" +
" </source>\n";
library_geometries += "<source id=\"meshId"+i+"-tex0\" name=\"meshId"+i+"-tex0\">\n" +
" <float_array id=\"meshId"+i+"-tex0-array\" count=\""+objV.size()*2+"\">" +
tex_array+
"</float_array>\n" +
" <technique_common>\n" +
" <accessor count=\""+objV.size()+"\" offset=\"0\" source=\"#meshId"+i+"-tex0-array\" stride=\"2\">\n" +
" <param name=\"S\" type=\"float\" />\n" +
" <param name=\"T\" type=\"float\" />\n" +
" </accessor>\n" +
" </technique_common>\n" +
" </source>\n";
library_geometries += " <vertices id=\"meshId"+i+"-vertices\">\n" +
" <input semantic=\"POSITION\" source=\"#meshId"+i+"-positions\" />\n" +
" </vertices>\n";
library_geometries += "<polylist count=\"900\" material=\"defaultMaterial\">\n" +
" <input offset=\"0\" semantic=\"VERTEX\" source=\"#meshId"+i+"-vertices\" />\n" +
" <input offset=\"0\" semantic=\"NORMAL\" source=\"#meshId"+i+"-normals\" />\n" +
" <input offset=\"0\" semantic=\"TEXCOORD\" source=\"#meshId"+i+"-tex0\" set=\"0\" />\n" +
" <vcount>" +
vcount+
"</vcount>\n" +
" <p>" +
p+
"</p>\n" +
" </polylist>\n" +
" </mesh>\n" +
" </geometry>\n";
library_visual_scenes+=
" <node id=\"Cylinder_"+(i+1)+"\" name=\"Cylinder_"+(i+1)+"\" type=\"NODE\">\n" +
" <matrix sid=\"matrix\">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>\n" +
" <instance_geometry url=\"#meshId"+i+"\">\n" +
" <bind_material>\n" +
" <technique_common>\n" +
" <instance_material symbol=\"defaultMaterial\" target=\"#material"+i+"\">\n" +
" <bind_vertex_input semantic=\"CHANNEL0\" input_semantic=\"TEXCOORD\" input_set=\"0\"/>\n" +
" </instance_material>\n" +
" </technique_common>\n" +
" </bind_material>\n" +
" </instance_geometry>\n" +
" </node>\n";
}
library_images += " </library_images>\n";
library_effects += " </library_effects>\n";
library_materials += " </library_materials>\n";
library_geometries += " </library_geometries>\n";
library_visual_scenes +=" </visual_scene>\n" +
" </library_visual_scenes>\n";
Collada += asset +
library_images +
library_effects+
library_effects+
library_materials+library_geometries+
" <library_controllers>\n" +
" </library_controllers>\n"+
library_visual_scenes+" " +
" <scene>\n" +
" <instance_visual_scene url=\"#models.obj\" />\n" +
" </scene>\n" +
"</COLLADA>";
CreateObj(objFilename,Collada);
createZip(createPath+"\\archive.zip",createPath);
return createPath;
}
/**
* 得到最大最小值。
*
* @param features 示例参数 {"features"}
* @return MaxMin
*/
private static Double[] getMaxMin(JsonNode features){
Double[] MaxMin = new Double[2];
MaxMin[0] = -100000000000000.0;
MaxMin[1] = -100000000000000.0;
for(int i =0;i<features.size();i++) {
JsonNode data1 = features.get(i).get("geometry");
JsonNode data2 = data1.get("coordinates");
for (int z = 0; z < data2.size(); z++) {
JsonNode data5 = data2.get(z);
System.out.println(data5.size());
if (data5.size() == 2) {
// Double[] data3 = CoordinateConverter(data5.get(0), data5.get(1));
Double[] data3 ={
data5.get(0).asDouble(),data5.get(1).asDouble()};
if (MaxMin[0] < data3[0]) {
MaxMin[0] = data3[0];
}
if (MaxMin[1] < data3[1]) {
MaxMin[1] = data3[1];
}
}
}
}
return MaxMin;
}
/**
* 创造obj文件。
*
* @param objFilename 示例参数 {"features"}
* @param mtlFilename 示例参数 {"features"}
* @param mtl 示例参数 {"features"}
* @param objAll 示例参数 {"features"}
* @return MaxMin
*/
private static void CreateObj(
String objFilename,
String mtlFilename
) throws IOException{
FileWriter mtlWriter = new FileWriter(objFilename);
mtlWriter.write(mtlFilename);
mtlWriter.close();
System.out.println("Dae模型文件已生成。");
}
/**
* 创造压缩文件。
*
* @param zipFile 示例参数 {"features"}
* @param sourceFolder 示例参数 {"features"}
* @return MaxMin
*/
private static void createZip(String zipFile,String sourceFolder) throws IOException {
File file = new File(sourceFolder);
file.createNewFile();
// 创建输出压缩文件流
try (FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(fos)) {
// 压缩文件夹及其内容
compressFolder(new File(sourceFolder), zos, "",zipFile);
System.out.println("文件夹及其内容已成功压缩为:" + zipFile);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 创造压缩文件。
*
* @param folder 示例参数 {"features"}
* @param zos 示例参数 {"features"}
* @param parentPath 示例参数 {"features"}
* @param excludeFile 示例参数 {"features"}
* @return MaxMin
*/
private static void compressFolder(File folder, ZipOutputStream zos, String parentPath, String excludeFile) throws IOException {
for (File file : folder.listFiles()) {
if (file.isDirectory()) {
// 递归压缩子目录
compressFolder(file, zos, parentPath + file.getName() + "/", excludeFile);
} else {
// 排除zip文件
if (!file.getAbsolutePath().equals(excludeFile) && !isZipFile(file)) {
// 压缩文件
String entryPath = parentPath + file.getName();
zos.putNextEntry(new ZipEntry(entryPath));
try (FileInputStream fis = new FileInputStream(file)) {
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}
}
zos.closeEntry();
}
}
}
}
/**
* 排除压缩文件。
*
* @param file 示例参数 {"features"}
* @return MaxMin
*/
private static boolean isZipFile(File file) {
String fileName = file.getName();
return fileName.endsWith(".zip") || fileName.endsWith(".ZIP");
}
//添加压缩包
private static void addToZip(File file, ZipOutputStream zos, String parentFolder) throws IOException {
FileInputStream fis = new FileInputStream(file);
// 获取文件相对于父文件夹的路径
String entryPath = parentFolder + file.getName();
// 创建ZipEntry对象并设置名称
ZipEntry entry = new ZipEntry(entryPath);
// 将ZipEntry对象添加到ZipOutputStream中
zos.putNextEntry(entry);
// 从输入流中读取数据并写入压缩文件中
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer)) >= 0) {
zos.write(buffer, 0, length);
}
// 关闭当前条目并将流定位到下一个条目的开头
zos.closeEntry();
fis.close();
}
public static char generateRandomLetter() {
Random random = new Random();
int randomNumber = random.nextInt(26); // 生成一个0到25之间的随机数
char randomLetter = (char) (randomNumber + 'A'); // 将随机数转换为对应的大写字母
return randomLetter;
}
private static Double[] CoordinateConverter(JsonNode longitude,JsonNode latitude){
double lonRad = Math.toRadians(longitude.asDouble());
double latRad = Math.toRadians(latitude.asDouble());
// 椭球体参数
double a = 6378137; // 长半轴
double e = 0.081819190842621; // 第一偏心率的平方根
// 计算转换后的坐标
double x = a * lonRad;
double y = a * Math.log(Math.tan(Math.PI / 4 + latRad / 2) * Math.pow((1 - e * Math.sin(latRad)) / (1 + e * Math.sin(latRad)), e / 2));
Double[] data =new Double[2];
data[0] = x;
data[1] = y;
return data;
}
private static void CreateDirPath(String folderPath)throws IOException{
File folder = new File(folderPath);
if (folder.mkdir()) {
// System.out.println("Folder created successfully.");
} else {
// System.out.println("Failed to create folder.");
}
}
//创建文件
private static void CreateDir(String objFilename) throws IOException {
File file = new File(objFilename);
if (file.createNewFile()) {
} else {
}
}
//导出纹理
private static void loadTextrue(String base64String,String outputPath) throws IOException {
String modifiedStr = base64String.substring(1, base64String.length() - 1);
String[] a= modifiedStr.split(",");
byte[] imageBytes = Base64.getDecoder().decode(a[1]);
// 创建输出流
OutputStream outputStream = new FileOutputStream(outputPath);
// 将字节数组写入输出流
outputStream.write(imageBytes);
// 关闭输出流
outputStream.close();
}
@PostMapping("/getGeojson")
@CrossOrigin(origins = "*")
public ResponseEntity<byte[]> downloadFile(@RequestBody String geojson, HttpServletResponse response) throws IOException {
ObjModelGenerator objModelGenerator = new ObjModelGenerator();
String filePath = LoadObj(geojson);
String zip = filePath+"\\archive.zip";
byte[] fileBytes = getFileBytes(zip);
// 设置响应头部信息
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", "archive.zip");
deleteFolder(new File(filePath));
return new ResponseEntity<>(fileBytes, headers, HttpStatus.OK);
}
//得到压缩包文件流
private byte[] getFileBytes(String filePath) throws IOException {
File file = new File(filePath);
byte[] fileBytes = new byte[(int) file.length()];
try (FileInputStream fis = new FileInputStream(file)) {
fis.read(fileBytes);
}
return fileBytes;
}
//删除生成的文件
private static void deleteFolder(File folder) {
if (folder.isDirectory()) {
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
deleteFolder(file);
}
}
}
// 删除文件或空目录
folder.delete();
}
}
文章浏览阅读122次。还是A+BTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24568Accepted Submission(s): 11729Problem Description读入两个小于10000的正整数A和B,计算A+B。...
文章浏览阅读419次。HEADERS:在BASIC的基础上,额外记录了请求和响应的头信息。FULL:记录所有请求和响应的明细,包括头信息、请求体、元数据。BASIC:仅记录请求的方法,URL以及响应状态码和执行时间。NONE:不记录任何日志信息,这是默认值。配置Feign日志有两种方式;方式二:java代码实现。注解中声明则代表某服务。方式一:配置文件方式。_feign 日志设置
文章浏览阅读155次。将容器管理的持久性 Bean 用于面向服务的体系结构本文将介绍如何使用 IBM WebSphere Process Server 对容器管理的持久性 (CMP) Bean的连接和持久性逻辑加以控制,使其可以存储在非关系数据库..._javax.ejb.objectnotfoundexception: no such entity!
文章浏览阅读1.5k次。基础java练习题一、递归实现跳台阶从第一级跳到第n级,有多少种跳法一次可跳一级,也可跳两级。还能跳三级import java.math.BigDecimal;import java.util.Scanner;public class Main{ public static void main(String[]args){ Scanner reader=new Scanner(System.in); while(reader.hasNext()){ _java 递归例题
文章浏览阅读1.5k次,点赞6次,收藏6次。目录1.串应用- 计算一个串的最长的真前后缀题目描述输入输出样例输入样例输出题解2.字符串替换(string)题目描述输入输出样例输入样例输出题解3.可重叠子串 (Ver. I)题目描述输入输出样例输入样例输出题解4.字符串操作(string)题目描述输入输出样例输入样例输出题解1.串应用- 计算一个串的最长的真前后缀题目描述给定一个串,如ABCDAB,则ABCDAB的真前缀有:{ A, AB,ABC, ABCD, ABCDA }ABCDAB的真后缀有:{ B, AB,DAB, CDAB, BCDAB_对存储在string数组内的所有以字符‘a’开始并以字符‘e’结尾的单词做加密处理。
文章浏览阅读68次。西安交通大学/算法设计与问题求解/树与二叉树/MOOC_算法设计与问题求解西安交通大学
文章浏览阅读1.6k次。问题:在Vue项目中出现如下错误提示:[Vue warn]: Computed property "totalPrice" was assigned to but it has no setter. (found in <Anonymous>)代码:<input v-model="totalPrice"/>原因:v-model命令,因Vue 的双向数据绑定原理 , 会自动操作 totalPrice, 对其进行set 操作而 totalPrice 作为计..._computed property "totalprice" was assigned to but it has no setter.
文章浏览阅读60次。十分暴力而简洁的解决方式:读取P和T的位置并自动生成唯一正确答案,将题给测点与之对比,不一样就给我爬!_basic 1003 case 1
文章浏览阅读422次。原标题:详解将Web项目War包部署到Tomcat服务器基本步骤详解将Web项目War包部署到Tomcat服务器基本步骤1 War包War包一般是在进行Web开发时,通常是一个网站Project下的所有源码的集合,里面包含前台HTML/CSS/JS的代码,也包含Java的代码。当开发人员在自己的开发机器上调试所有代码并通过后,为了交给测试人员测试和未来进行产品发布,都需要将开发人员的源码打包成Wa..._/opt/bosssoft/war/medical-web.war/web-inf/web.xml of module medical-web.war.
文章浏览阅读3k次,点赞3次,收藏13次。# -*- coding: utf-8 -*-# 简述:这里有四个数字,分别是:1、2、3、4#提问:能组成多少个互不相同且无重复数字的三位数?各是多少?def f(n):list=[]count=0for i in range(1,n+1):for j in range(1, n+1):for k in range(1, n+1):if i!=j and j!=k and i!=k:list.a..._python求从0到9任意组合成三位数数字不能重复并输出
文章浏览阅读1k次,点赞3次,收藏2次。<el-table-column prop="studentSex" label="性别" :formatter="sex"></el-table-column>然后就在vue的methods中写方法就OK了methods: { sex(row,index){ if(row.studentSex == 1){ return '男'; }else{ return '女'; }..._elementui table 性别
文章浏览阅读1.1k次。java文件操作之移动文件到指定的目录_java中怎么将pro.txt移动到design_mode_code根目录下