jeecgboot/JeecgBoot · error · JeecgBootException
网页URL格式不正确,请以http://或https://开头
Error message
网页URL格式不正确,请以http://或https://开头
What it means
Thrown by EmbeddingHandler.parseWebPage() when the website URL from document metadata does not match LLMConsts.WEB_PATTERN, which is the regex ^(http|https)://.* — requiring the URL to start with http:// or https://. This is a format validation before attempting to fetch and parse the web page.
Source
Thrown at jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/handler/EmbeddingHandler.java:773
}
/**
* 解析网页内容,使用Jsoup爬取并转换为Markdown
*
* @param doc 知识库文档(metadata中需包含website字段)
* @return Markdown格式的网页内容
* @date 2026/3/19
*/
private String parseWebPage(AiragKnowledgeDoc doc) {
String metadata = doc.getMetadata();
AssertUtils.assertNotEmpty("请先配置网页URL", metadata);
JSONObject metadataJson = JSONObject.parseObject(metadata);
String website = metadataJson.getString(LLMConsts.KNOWLEDGE_DOC_METADATA_WEBSITE);
AssertUtils.assertNotEmpty("请先配置网页URL", website);
Matcher matcher = LLMConsts.WEB_PATTERN.matcher(website);
if (!matcher.matches()) {
throw new JeecgBootException("网页URL格式不正确,请以http://或https://开头");
}
try {
WebPageParser webPageParser = new WebPageParser();
String content = webPageParser.parseToMarkdown(website);
if (oConvertUtils.isEmpty(content)) {
throw new JeecgBootException("网页内容为空,请检查URL是否可访问");
}
log.info("网页解析成功, URL: {}, 内容长度: {}", website, content.length());
return content;
} catch (JeecgBootException e) {
throw e;
} catch (Exception e) {
log.error("网页解析失败, URL: {}, 错误: {}", website, e.getMessage(), e);
throw new JeecgBootException("网页解析失败: " + e.getMessage());
}
}
View on GitHub (pinned to 96fb33f5ec)
Solutions
- Ensure the website URL in the document metadata starts with 'http://' or 'https://'.
- If building the metadata programmatically, prepend 'https://' when the protocol is missing.
- Trim whitespace from the URL before storing it in metadata.
Example fix
// before
String website = "www.example.com/page"; // stored in metadata
// after
String website = "www.example.com/page";
if (!website.startsWith("http://") && !website.startsWith("https://")) {
website = "https://" + website;
}
metadataJson.put(LLMConsts.KNOWLEDGE_DOC_METADATA_WEBSITE, website); Defensive patterns
Strategy: validation
Validate before calling
if (website == null || (!website.startsWith("http://") && !website.startsWith("https://"))) {
throw new JeecgBootException("网页URL必须以http://或https://开头");
} Type guard
private static boolean isValidWebUrl(String url) {
return url != null && Pattern.compile("^(http|https)://.*").matcher(url).matcher(url).matches();
} Prevention
- Always prepend 'https://' to URLs missing a protocol before storing in metadata.
- Trim whitespace from URLs before validation.
- Use URL-based input validation at the frontend to enforce protocol prefix.
When it happens
Trigger: A knowledge-base document of web-page type whose metadata JSON 'website' field does not begin with 'http://' or 'https://'. For example: 'ftp://example.com', 'www.example.com', 'example.com/page', or a URL with a leading space.
Common situations: User enters a URL without the protocol prefix (e.g. 'www.example.com' instead of 'https://www.example.com'); the metadata field was populated programmatically without protocol normalization; trailing/leading whitespace prevents the regex match.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/9299ec6953c6f711.
Report an issue: GitHub.