第一个 JSP:调用 Javascript 函数:
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="continueTour" onclick="launchTutorial()">Take a Quick Tour</button>
</div>
Javascript 函数:
function launchTutorial(){
var enjoyhint_instance = new EnjoyHint({});
var enjoyhint_script_steps = [
{
"next #newAuthorizationActive": 'To create an authorization form'
}
];
enjoyhint_instance.set(enjoyhint_script_steps);
enjoyhint_instance.run();
//Here's where i'm accessing the 'exportFile' controller method (shown further below)
$.ajax({
type : "POST",
url : $('#authorizationResourceURL').val(),
data : {action: "redirectToEmpInfoForAuthTour", tourStatus : 0},
success : function(data){
alert('success');
document.open();
document.write(data);
document.close();
}
});
Controller 中的方法:
@ResourceMapping
protected void exportFile(ResourceRequest request, ResourceResponse response) throws IOException {
String action = ParamUtil.getString(request, "action", "");
if(action.equals("redirectToEmpInfoForAuthTour"))
{
//This is where I want to return the 2nd JSP from
}
我在这里要寻找的内容的简要背景:
我有一个 JSP(第一个 JSP),我试图向用户展示该 portlet 的教程(使用 Enjoyhints)。作为本教程的一部分,我需要突出显示 portlet 的不同页面 (JSP) 上的元素(选择框、文本字段)。因此,在 Javascript 函数中,我首先突出显示第一个 JSP 上的元素(这个突出显示部分是由 Enjoyhints 处理的)(并且效果很好),现在我想向用户显示第二个 JSP,并且使用enjoyhints,突出显示第二个JSP 中的某些元素,等等第三个和第四个JSP 中的元素。
如果有人有其他方法可以做到这一点,请告诉我。 这里的主要问题是我需要突出显示的元素位于不同的 JSP 页面(同一 portlet 的)上。如果所有元素都在同一页面上,事情就会很简单。
我使用 Liferay Portal 和 Spring Portlet MVC 作为我的设计模式。
更新:Here's another thing that I've been trying to achieve the same thing, but no luck
最佳答案
您可以定义资源方法,如下所示,返回类型为 ModelAndView 并在弹出窗口中显示整个 jsp 内容或附加到现有的 html 中。
@ResourceMapping
protected ModelAndView exportFile(ModelMap model,ResourceRequest request, ResourceResponse response){
}
关于javascript - Liferay - 如何从 @ResourceMapping 带注释的方法渲染 JSP。通过 AJAX 从 JS 文件调用此方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38107823/