我正在制作一个动态的表格.A Field有一个值列表.每个值都由一个字符串表示.
export class Field{
name: string;
values: string[] = [];
fieldType: string;
constructor(fieldType: string) {this.fieldType = fieldType;}
}
Run Code Online (Sandbox Code Playgroud)
我的组件中有一个函数,它为字段添加了一个新值.
addValue(field){
field.values.push("");
}
Run Code Online (Sandbox Code Playgroud)
值和按钮在我的HTML中显示如下.
<div id="dropdown-values" *ngFor="let value of field.values; let j=index">
<input type="text" class="form-control" [(ngModel)]="field.values[j]" [name]="'value' + j + '.' + i"/><br/>
</div>
<div class="text-center">
<a href="javascript:void(0);" (click)="addValue(field)"><i class="fa fa-plus-circle" aria-hidden="true"></i></a>
</div>
Run Code Online (Sandbox Code Playgroud)
只要在输入值中写入一些文本,输入就会失去焦点.如果我向字段添加许多值,并且我在一个值输入中写入一个字符,则输入将失去焦点,并且字符将写入每个输入.
我编写了一些代码来获取StreamingAssets中文件夹内的所有文件夹,然后获取该文件夹中的所有文件.它在Windows上运行良好,但我无法在Android上运行它.
这是代码:
foreach (string s in Directory.GetDirectories(model.path + "/Levels")) {
GameObject el = (GameObject)Instantiate(listButton, Vector3.zero, Quaternion.identity);
el.transform.SetParent(grid1.transform);
string[] words = s.Split('/');
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
words = s.Split('\\');
#endif
el.GetComponentInChildren<Text>().text = words[words.Length - 1];
el.GetComponent<Button>().onClick.AddListener(() => {
MapSizeButtonClick(Int32.Parse(el.GetComponentInChildren<Text>().text));
});
}
Run Code Online (Sandbox Code Playgroud)
由于'\',我不得不为Windows添加#if UNITY_STANDALONE_WIN.
然后对于该文件夹中的文件,我写了这个:
foreach (string s in Directory.GetFiles(model.path + "/Levels/" + model.mapSize + "/" + model.colorNumber)) {
string[] words = s.Split('/');
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
words = s.Split('\\');
#endif
words = words[words.Length - 1].Split('.');
if (words[1] == "json") {
GameObject …Run Code Online (Sandbox Code Playgroud) 应该在Spring Boot Rest API中使用哪个层进行验证.我有一些模型,端点和DTO.我在DTO中添加了一些@NotNull和@Size注释.我@Valid在端点中添加了注释以及@RequestParam注释.
但现在我想知道我是否应该在@Entity课堂上进行验证?我觉得这将是一个重复的代码.但我读到一层不应该依赖另一层.
在热重载期间,Webpack 会卡住95% emitting CopyPlugin几秒钟。
我的公共文件夹中有很多文件,大部分是图像(大约 1GB),它们必须显示在我的 VueJS 应用程序上。如果我删除它们,我就不再有问题了。
这是我的package.json依赖项:
{
...
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.4",
"register-service-worker": "^1.7.1",
"vue": "^2.6.11",
"vue-router": "^3.1.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-pwa": "~4.3.0",
"@vue/cli-plugin-router": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 vue.config.js 文件:
const path = require("path");
function resolveSrc(_path) {
return path.join(__dirname, _path);
}
// vue.config.js …Run Code Online (Sandbox Code Playgroud) 我正在尝试对上传REST API的文件进行单元测试.我在网上找到了一些使用Pillow生成图像的代码,但它无法序列化.
这是我生成图像的代码:
image = Image.new('RGBA', size=(50, 50), color=(155, 0, 0))
file = BytesIO(image.tobytes())
file.name = 'test.png'
file.seek(0)
Run Code Online (Sandbox Code Playgroud)
然后我尝试上传这个图片fille:
return self.client.post("/api/images/", data=json.dumps({
"image": file,
"item": 1
}), content_type="application/json", format='multipart')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
<ContentFile: Raw content> is not JSON serializable
Run Code Online (Sandbox Code Playgroud)
如何变换枕头图像以使其可序列化?
所以我大部分时间都在使用 Spring Data Repositories。但我遇到了一个用例,我无法使用 Spring 存储库来检索我需要返回给客户端的实体。所以我的类ResourceEntity是一个 Spring 数据实体。我想将这个实体作为ResourceProjection接口返回。
@Getter
@Setter
@NoArgsConstructor
@Entity
public class ResourceEntity{
private Long id;
private String name;
private String anotherFieldThatIsNotInTheProjection;
}
public interface ResourceProjection {
Long getId();
String getName();
}
Run Code Online (Sandbox Code Playgroud)
通常对于 Spring 存储库,我会定义类似的内容:
public interface ResourceRepository extends PagingAndSortingRepository<ResourceEntity, Long> {
Optional<ResourceProjection> getById(Long id);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我无法使用 Spring Data 生成的“自动代理”来自动实现实体数据的投影。
所以我的问题是:有没有办法“手动”将实体转换为投影?
我想到的另一个解决方案是返回实体并使用 @JsonIgnore 之类的 Jackson 注释来防止返回一些数据,但这对于我的代码编写方式来说并不是最佳的。
否则,我始终可以创建一个 DTO 类来填充来自实体的数据。但由于我已经为其他目的创建了投影,所以我想避免创建第二个“DTO”。
我正在寻找一种在Windows 7 64位下使用MySQL和Python 2.7的工具.
我搜索了一下这些:
MySQLdb - _http://sourceforge.net/projects/mysql-python/
SQLAlchemy - _http://www.sqlalchemy.org/
SQLObject - _http://sqlobject.org/
ourSQL - _http://pythonhosted.org/oursql/
Connector/Python - _http://dev.mysql.com/downloads/connector/python/1.0.html
SQLite - _http://www.sqlite.org/
Psycopg2 - _http://wiki.postgresql.org/wiki/Psycopg2_Tutorial (postgreSQL)
pandaSQL - _https://github.com/yhat/pandasql
python-sql - _https://code.google.com/p/python-sql/
SnakeSQL - http://pythonweb.org/projects/snakesql/
Run Code Online (Sandbox Code Playgroud)
您有什么推荐的吗 ?
谢谢 !
安托万
我在Chrome上有一个完美的jquery功能,但它不适用于IE ...每次我在文本框#form中更改某些内容时,服务器都会获取获取AJAX请求但不在IE上
$("#form").on('input', function() {
$("#value").val($("#value").val().toUpperCase());
var postdata = {value: $("#value").val()} ;
$.get('/search', postdata, function(data) {
var result = ("Type : " + data['type'] + "<br/>Project name : " + data['project_name'] + "<br/>Project version : " + data['project_version'] + "<br/>Product name : " + data['product_name'] + "<br/>Product version : " + data['product_version'] + "<br/>Lib op : " + data['libop'])
$("#print").html(result) ;
});
});
Run Code Online (Sandbox Code Playgroud)
你有解决方案吗?
谢谢 !最好的祝福,
Servietsky
我是着色器的新手,我正在尝试为一些非常简单的低聚水制作着色器。我创建了这个简单的表面着色器,它可以更改顶点高度。
问题在于,它没有收到gif中所见的阴影,并且边缘上有奇怪的行为。
我究竟做错了什么?
Shader "Ramble/LowPolyWater" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
_Emission ("Emission", Color) = (1,1,1,1)
_ScrollYSpeed("Scroll y speed", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _Emission;
float _ScrollYSpeed;
void vert (inout appdata_full v)
{
v.vertex.z += frac(sin( dot(v.vertex.xyz ,float3(12.9898,78.233,45.5432) )) * 43758.5453) * sin(_Time.y) * _ScrollYSpeed;
}
void surf (Input …Run Code Online (Sandbox Code Playgroud) 我试图在平面地图上随机生成块,并使它们不会相互重叠.我已经制作了一个地图大小(500x500)的矩阵(c#数组),这些块的比例在1到5之间.代码可以工作但是如果生成的块与另一个块重叠,它就会被破坏而不会在其他地方重新生成.
我尝试生成的1000个块中只有大约80个不与另一个块重叠.
这是地图的图片,生成了大约80个块,绿色方块是块
void generateElement(int ratio, int minScale, int maxScale, GameObject g) {
bool elementFound = false;
for (int i = 0; i < ratio * generationDefault; i++) {
GameObject el;
// Randomly generate block size and position
int size = Random.Range(minScale, maxScale + 1);
int x = Random.Range(0, mapSizex + 1 - size);
int y = Random.Range(0, mapSizey + 1 - size);
// Check if there is already an element
for (int j = x; j < x + …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个带有 2 个画布的像素编辑器。第一个画布显示包含像素的第二个画布。第一个画布使用drawImage来定位和缩放第二个画布。
当第二个画布缩放得小于其原始尺寸时,它开始出现故障。
这是以原始尺寸显示的画布。当我放大时,第二个画布变得更大,一切都完美运行。
然而,当我缩小时,网格和背景(透明度)的表现非常奇怪。
要在第一个画布上绘制第二个画布,我使用该函数
ctx.drawImage(drawCanvas, offset.x, offset.y, width * pixelSize, height * pixelSize);
Run Code Online (Sandbox Code Playgroud)
我读过多次迭代中的缩放可能会提供更好的图像质量,但我不确定画布。
当用户缩小时,我可以以较低的分辨率完全重绘第二个画布,但这对 CPU 来说有点沉重。
还有我不知道的更好的解决方案吗?
我刚刚在Spring REST API的多个文件中编写了一些代码,现在出现Jackson错误。
org.springframework.context.ApplicationContextException: Unable to start
embedded container; nested exception is
org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:168) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:160) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
... 11 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Boot 制作 API,但我似乎从未设法初始化惰性集合。对我有用的唯一解决方案是将其更改为热切,但这不是解决方案。
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "user")
public class UserEntity {
@Id
@GeneratedValue
private Long id;
@Column(unique = true)
String email;
@ElementCollection(fetch = LAZY)
List<String> roles = new ArrayList<>();
public UserEntity(String email) {
this.email = email;
}
}
Run Code Online (Sandbox Code Playgroud)
@Order(Ordered.LOWEST_PRECEDENCE)
@Component
public class AuthFilter extends OncePerRequestFilter {
Logger LOG = LoggerFactory.getLogger(AuthFilter.class);
@Autowired
UserRepository userRepository;
@Override
@Transactional
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication != null && …Run Code Online (Sandbox Code Playgroud) spring ×4
java ×3
javascript ×3
hibernate ×2
rest ×2
spring-boot ×2
android ×1
angular ×1
assets ×1
c# ×1
canvas ×1
cg ×1
css ×1
dictionary ×1
directory ×1
django ×1
generator ×1
html ×1
jackson ×1
jpa ×1
jquery ×1
mysql ×1
ngfor ×1
python ×1
python-2.7 ×1
random ×1
shader ×1
spring-data ×1
spring-mvc ×1
sqlite ×1
unity5 ×1
validation ×1
vue-cli ×1
vue.js ×1
webpack ×1