angular - 如何将 jsp 字符串传递给角度输入参数?
问题描述
我正在尝试将 JSP 字符串值传递给角度输入参数。
使用“ ng new
”,我只需在 index.html 中编辑这一行,就构建了我非常简单的 Angular 项目:
<app-root [jspstring]="<%= jspstring%>"></app-root>
所以我运行“ ng build --prod
”,并将所有文件复制到使用 MVC Struts 1.1(不要侮辱我)和 JSP 构建的 Web 应用程序中。
然后我将 index.html 的扩展名更改为 index.jsp 以使用如下 JSP 语法:
<% String jspstring = (String) request.getAttribute("jspstring"); %>
...我想将“jspstring”(用请求属性中的字符串正确填充)传递给“ @Input() jspstring: string;"
(在 angular app.component.ts 中正确定义)
然后我用我的struts ForwardAction直接访问index.jsp页面(struts正常运行)。
一切正常(js 和 css),但未设置“@Input() jspstring”。
你有什么解决办法吗?提前谢谢你。
这是 index.jsp 文件:
<html lang="en">
<head>
<meta charset="utf-8">
<title>StrutsWithAngular</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="lib/favicon.ico">
<link rel="stylesheet" href="lib/styles.3ff695c00d717f2d2a11.css">
</head>
<% String jspstring = (String) request.getAttribute("jspstring"); %>
<body>
This work fine: <%= jspstring %>
....but angular input param jspstring is not set:
<app-root [jspstring]="<%= jspstring%>"></app-root>
<script src="lib/runtime.0e49e2b53282f40c8925.js" defer></script>
<script src="lib/polyfills.8c151b8375e767ff858f.js" defer></script>
<script src="lib/main.823494c4e9f7a31ecf88.js" defer></script>
</body>
</html>
解决方案
推荐阅读
- ios - 快速单击 UITableView 中的单元格时折叠部分
- sql-server - 如何将我的 CASE 语句限制为每次评估 1 行
- c++ - g ++:“仅编译”和“编译和组装”选项之间的区别?
- php - 共享服务器上的 PHP V8J
- ruby-on-rails - 活动模型序列化器:渲染值数组仅渲染第一个值
- windows - Windows 7 上的代码签名驱动程序失败并显示 0xC0000428
- lua - Lua 匹配字符串中字符后的所有内容
- javascript - 从数据层获取 IE 11 上的对象值
- ios - Xamarin.forms.iOS 通知错误
- vba - VBA从表1中的单元格引用中选择另一张表