我想上传一个图像并将其存储在服务器上,然后用h:graphicImage显示它?我想将它存储在应用程序的"资源/图像"中.我正在使用glassfish 4.现在,文件转到"domain1\generated\jsp\FileUpload".谢谢
我的表格
<h:form id="form" enctype="multipart/form-data">
<h:messages/>
<h:panelGrid columns="2">
<h:outputText value="File:"/>
<h:inputFile id="file" value="#{uploadPage.uploadedFile}"/>
</h:panelGrid>
<br/><br/>
<h:commandButton value="Upload File" action="#{uploadPage.uploadFile}"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
我的豆子
@Named
@ViewScoped
public class UploadPage {
private Part uploadedFile;
public void uploadFile(){
File file = File.createTempFile("somefilename-", ".jpg", new File("C:\\var\\webapp\\images"));
uploadedFile.write(file.getAbsolutePath());
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个JSF输入文本组件,其id为search.在生成的HTML输出中,它看起来像这样j_idt17:search,但数字17会不时变化.如何让它保持一个?
有没有办法设置页脚样式,所以当有内容(超过浏览器的高度)时,它将位于页面的底部(隐藏),但如果内容不足,它将粘在底部边缘浏览器?
我想将查看可由授权和匿名用户访问的网页的数据库(日期和用户)保存在数据库中。有没有一种方法可以使操作同时使用这两种类型,因为如果操作是[AllowAnonymous],则用户未经身份验证,我无法检索用户 ID,如果操作是[Authorize]匿名用户,则无法访问该页面。
[HttpGet]
[Route("{id}/Detail")]
[AllowAnonymous]
[ResponseType(typeof(JsonArticleDetail))]
public IHttpActionResult GetArticle(int id)
{
...
var entity = this.DbContext.Articles.Find(id);
var applicationUserId = User.Identity.IsAuthenticated ? User.Identity.GetUserId() : null;
entity.ArticleViews.Add(new ArticleView
{
ViewedOn = DateTime.UtcNow,
ApplicationUserId = applicationUserId
});
this.DbContext.SaveChanges();
return Ok(article);
}
Run Code Online (Sandbox Code Playgroud) 有没有办法为复选框和带边框的标签设置样式,因此用户只能看到标签(隐藏复选框),当用户点击标签时,标签会更改背景颜色和文字?单击该复选框也可以使用此单击.如果有办法,我该怎么做?
要么
如何隐藏复选框并只留下标签可以改变颜色吗?
如何将Part转换为Blob,以便将其存储在MySQL中?这是一张图片.谢谢
我的表格
<h:form id="form" enctype="multipart/form-data">
<h:messages/>
<h:panelGrid columns="2">
<h:outputText value="File:"/>
<h:inputFile id="file" value="#{uploadPage.uploadedFile}"/>
</h:panelGrid>
<br/><br/>
<h:commandButton value="Upload File" action="#{uploadPage.uploadFile}"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
我的豆子
@Named
@ViewScoped
public class UploadPage {
private Part uploadedFile;
public void uploadFile(){
}
}
Run Code Online (Sandbox Code Playgroud) 这两个文件夹有什么区别?为什么我的bean必须进入资源,所以我的网络应用程序工作?
src/main/java Application/Library sources
src/main/resources Application/Library resources
Run Code Online (Sandbox Code Playgroud) 我有这两个表,并且已经有一些数据。
CREATE TABLE `system_user_data` (
`id_user` bigint(20) NOT NULL AUTO_INCREMENT,
`user_login` varchar(15) DEFAULT NULL,
PRIMARY KEY (`id_user`)
) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=utf8;
CREATE TABLE `system_user_tokens` (
`id_token` bigint(20) NOT NULL AUTO_INCREMENT,
`token_user` bigint(20) DEFAULT NULL,
`token_token` varchar(20) DEFAULT NULL,
`token_createdate` date DEFAULT NULL,
PRIMARY KEY (`id_token`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
Run Code Online (Sandbox Code Playgroud)
当我尝试添加外键token_user = id_user时,出现错误。没有任何数据时,它正在工作。
alter table system_user_tokens add foreign key (token_user) references system_user_data (id_user);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`name`.`#sql-1b44_727`, …Run Code Online (Sandbox Code Playgroud) 我有相同的数组与字符串,但他们的it数组不正确排序,它是从我的电脑复制.items在浏览器中输入.
https://jsfiddle.net/acc8xf0g/
var items = ["hard", "intermediate", "easy"];
var it = [
"intermediate",
"hard",
"?asy"
];
items.sort(function(a, b) {
return a.localeCompare(b);
});
it.sort(function(a, b) {
return a.localeCompare(b);
})
$("#test").html(items.join(" "));
$("#test2").html(it.join(" "));
Run Code Online (Sandbox Code Playgroud) 如何用string一个char 创建一个JavaScript?
这是C#.
String text = new String('*',20);
Run Code Online (Sandbox Code Playgroud)
有一个简单的方法来做到这一点JavaScript?
jsf ×3
css ×2
css3 ×2
file-upload ×2
javascript ×2
asp.net ×1
blob ×1
element ×1
glassfish ×1
identifier ×1
java ×1
jsf-2.2 ×1
maven ×1
mysql ×1
sql ×1