我的代码是
\n\npublic enum PartsOfSpeech2 {\n\n n("noun"),\n wp("\xe6\xa0\x87\xe7\x82\xb9"),\n a("adjective"),\n d("conjunction"),\n ...;\nRun Code Online (Sandbox Code Playgroud)\n\n我想要哪个
\n\npublic enum PartsOfSpeech2 {\n\n n("noun"),\n wp("\xe6\xa0\x87\xe7\x82\xb9"),\n a("adjective"),\n d("conjunction"),\n %("noun");\nRun Code Online (Sandbox Code Playgroud)\n\n我可以有一个不在其中的默认值\xef\xbc\x8c 可以将其设置为默认值\xef\xbc\x9f\n因为我有一个类型是“%”,但枚举不支持%,所以我想要一个默认值来解决它
\n我的Controller使用“org.apache.commons.fileupload”实现了文件上传。看见:
@PostMapping("/upload")
public String upload2(HttpServletRequest request) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
boolean uploaded = false;
while (iter.hasNext() && !uploaded) {
FileItemStream item = iter.next();
if (item.isFormField()) {
item.openStream().close();
} else {
String fieldName = item.getFieldName();
if (!"file".equals(fieldName)) {
item.openStream().close();
} else {
InputStream stream = item.openStream();
// dosomething here.
uploaded = true;
}
}
}
if (uploaded) {
return "ok";
} else {
throw new BaseResponseException(HttpStatus.BAD_REQUEST, "400", "no file field or data file …Run Code Online (Sandbox Code Playgroud)